Drupal 7 - Term reference field: how to add new term? - drupal

I have some texonomies in my Drupal website. Some of them have additional fields. I have some fields of type Term reference in my content-types.
When I am creating a new node of a content-type, I would like to have the ability to add a new term to the taxonomy while I'm filling the form of the Content-Type (with an "add item" link/popup...).
I can do that if I use Entity Reference fields, but I cannot using Term reference field. Could you help me, please?
Thanks
UPDATE: I installed "Taxonomy access fix" module (https://www.drupal.org/project/taxonomy_access_fix) and it allows me to set capabilities per each taxonomy based on user role. Now I only need to add a new term to a Taxonomy on a form level using Term reference field (I canno use autocomplete because I need the user to see all possible values like with a dropdown).
Any help?

If you change your widget to the autocomplete widget, it will let you add new values.

I agree with #Dark FlameS, in fact we are using the autocomplete widget for some of our students to add types of trees in the biology lab and they tag each with the scientific name.
And since we dont know these scientific terms, we let them add taxonomy terms to the list.
Slight difference however, we use the module Autocomplete Deluxe. Works like magic for us.
You are able to see what taxonomy terms are already available by clicking into the text area.
And as you type a taxonomy term, you will see what other terms are similar. If a tag is new, it will be added. one thing, dont allow them to delete your tags. We learned this the hard way.
See the image below on what it looks like as you add a tag.
Above is what you will see when you are adding the taxonomy field in your content type, this is after you install the Autocomplete Deluxe module
Above is What the user sees when they add or select a taxonomy tag.

Related

Relating different content types in Drupal 7

I've just started learning Drupal 7 and I'm stuck on a problem.
I want to relate different content types using taxonomy. For example, how can I display blogs related to an article?
I know how to relate articles and basic pages but I don't know how can I relate blogs with articles?
Please help me.
Use reference field in blogs content type
like
field name is: related with
field type is reference
set reference type node
set node type is article
optional multivalued true
Now you have a relationship field in blogs
Now you can do every thing with this relationship
Hope this make sense
Thanks
You would create your taxonomy vocabulary and supply it with terms. On its own, this doesn't do anything, you need to add a field to each of your content types that are using this taxonomy.
If you go back to your content types, structure > content type > article. Here you would create a new field of type term reference. Inside the settings of the field you'd select your vocabulary and then also the widget eg. select list. You can re-use this field on the other content types where you want to share this vocabulary.
If you go back to your content for the types you added this field for and populate them with selections, when you view that page by default the term will appear as a link. If you click this link it will take you to a page view that will list all the other nodes that have that term form that vocabulary.
More information on taxonomies: https://www.drupal.org/docs/7/organizing-content-with-taxonomies/about-taxonomies
If you are creating a view and want to know how to pull in different tagged content there, I'd recommend reading this post which outlines the steps to do so https://drupal.stackexchange.com/questions/205921/how-do-i-show-related-content
The process:
Basic stages:
Create a “Content” view-block.
Add a contextual filter: “Has taxonomy term ID”.
Choose “provide a fixed value”.
(From type): “Taxonomy term ID from URL“.
Checking:
• Uncheck “Load default filter from the term page”. • Check “Load
default filter from node page, that’s good for related taxonomy
blocks”.
• Check “Limit terms by a vocabulary”. • Check your desired
vocabulary.
Select “Filter to items that share any term”.
Go down and check “Reduce duplicates”: This will several terms that relate to the same page – To appear. Only one will of them will.

Drupal 7 - Add a wrapper around related nodes on Taxonomy term page

On a taxonomy term page, the taxonomy term info is shown first, followed by related nodes. I want to add a wrapper div around the related nodes (ex. class="related-nodes").
taxonomy-terms.tpl.php controls the display of the taxonomy term's fields, but I'm not sure how the nodes show up. I was thinking about making a node template for the taxonomy and doing something like render($content['nodes']). However, I'm not sure what the $content key would be for the related nodes.
One approach is to enable the Taxonomy term view display (is disabled by default).
In the view config, you can add classes by clicking in Settings of Format option.
Hope it helps.
Regards.

Drupal change display based on vocabulary

I need to have terms related to a specific vocabulary use a custom view I have set up.
For example: I have a vocabulary called "Book Categories" with terms under it such as Humor, History, etc. When navigating to a term page (taxonomy/term/7), I would like to display just the book title and a custom book-cover field. By default, Drupal displays node title, teaser, and links on all taxonomy term pages. The problem I am having is I would like terms that fall under the "Book Categories" vocabulary to use my custom view, and all other terms to use the default view.
Is there a way around this? Any help is appreciated.
You can clone default taxonomy view and change fields section as you like.
In PAGE SETTINGS->PATH remove "%" and add taxonomy number of your Book Category (like "7")
In contextual filter delete all filters.
This view then should override default view.
Hope this helps.
There is a new module called Taxonomy Views Integrator that seems like it does what you want to do. Try it.

Drupal: Sub views?

I have a parent/child relationship (based on the cck node reference field).
Recipe Group contains a node reference to the type Recipe. It's a 1 to many relationship.
What I need to do is create a view that displays the recipe group information, and then under it, the recipes that have been assigned to it's cck field.
So
RecipeGroup1 - Title
Recipe1, Recipe2, Recipe3
RecipeGroup2 - Title
Recipe4, Recipe5, Recipe6
etc etc
I've created the view to pull the list of recipe groups.. but I have no idea how to retrieve the recipes that belong to the group?
I've tried googling, but we are on a tight time line and would appreciate any assistance.
Thanks.
Take a look at http://drupal.org/project/views_field_view. It lets you combine two views (groups, recipes), inserting the recipes view as a field into the groups view. Using this, you can have as many fields as you want for the group.
You can use the Views attach module to associate a view with a specific content type and display that view on that content type's node page.
There is a webcast here that demonstrates how the module can solve a problem similar to yours.
However, the webcast assumes your nodereference CCK field is on the child content type and is pointing to the parent content type, not the other way around like you have it.
Instead of using the nid of the recipe group as an argument to the view (as shown in the video) you may be able to use one of the recipe group's tokens (the nodereference field referencing its children). You can see that option at 9:32 in the video.
Whatever you decide to do, I think Views attach will likely be your answer.
Include the cck reference node field as an output field to your view. After, you can 'rewrite the output of this field'.. so that it looks however you want.
add noderefernce field in to views fileds
select check box to group field result in node ref field settings
theme that field as you want

Dynamic Fields for Drupal Content Type

I have a product, and I want it to have many changeable attributes so I did it with Taxonomy, now I have a list that holds "price, color, shape", how do I let a user choose from it within the "add product" page and let him write a color for instance?
UPDATE
I found something called Taxonomy Field.
That is almost exactly what I'm looking for.
It lets me have a list of taxonomy which I use as attributes
and even lets the user create new ones.
One thing is missing - I want a text field to be created for each attribute
the user chooses.
for example:
Attribute: Color Value: White
so the attribute Color is a Taxonomy field and the value is simply an empty text field created for it (I can't just add a text field because
the number of attributes is dynamic)
SOLVED
In the new Beta version of CCK there's a group
type that's called "MutliGroup" that does exactly what I wanted.
Turns out this issue has been discussed a lot and it seems
that they are adding it to the new CCK3 which would be stable
on Drupal7
Drat, a whole answer then I reread the comments and lost my post.
That answer boiled down to Autocomplete Widgets for CCK Text and Number, which is still a neat module to know about.
For the sort of hierarchical structure you describe with dynamic field availability, it sounds like you want some sort of javascripty hierarchical selection mechanism. Like, say Hierarchical Select.

Resources