View of Terms. How to get term synonym in Fields or via Custom field (php code)? - drupal

I am using Drupal 6, and Views 2.
For example, term has the alias “vocabulary/term1” (only one level, no nesting).
How do I obtain “term1” field for every item in View, displaying items of type Term?

The probably best/easiest way is to use the token of pathauto.
If you build links use the "output this field as link" feature, which converts the links to it's aliases automatically

Related

calling of one taxonomy from another taxonomy, so both of them have used in the same content type

Can we call one taxonomy term from another as a parent and child relation for example I need to click on product category and that show me product series page and when I click on product each series that will lead me to actual product detail means node, so I have two taxonomies category and series I am about to click on category to carry me to series page and then to click on series page to carry me to product detail page on the concern series”
no codebase problem
i am expecting that these two taxonomies may be used as i have mentioned in the question summary but, i can't do it so i hope some help in resolving this issue
Let's look at this answer, I hope it will help you.
Taxonomy terms from the same vocabulary filtered and referenced on multiple content types
To do this you’ll need to have the Entity Reference module installed. So get that out of the way quickly with drush dl entity reference -y and drush en entityreference -y if you haven't already.
First up, we need the taxonomy set up.
Let's demonstrate with the help of an image.
You’ll notice that these terms could be more or less grouped into two categories: Transport and Sleeping. One term (couchette) kinda fits both criteria and is there to exemplify the reason for not using 2 different vocabularies to handle the issue. Now we need to technically make the distinction between these terms as well and since they are entities, we can use a field for that.
So we can now go ahead and add a new field to this vocabulary of the type List (text) with whatever widget you’d like (and let’s call the field Type). You should make the allowed number of values unlimited and put the following in the allowed values list:
Edit each term and select the appropriate type. As expected, for the term couchette, you should select both options.
Now that we have our taxonomy squared away, it’s time to create a View that will handle the filtering of these terms. Because if we now add the Tags taxonomy term reference field to our content types in the normal fashion (as it is already present in the Article content type) we’ll be able to select all the terms in the vocabulary for all the content types. And that's not what we want now.
So create a drupal 7/8 View that shows taxonomy terms of the Tags vocabulary - let’s call it Tags Filter. Add 2 displays of the type Entity Reference and a filter of the field we added to our terms earlier. So for instance the first display can show the terms which have Sleeping selected and the other one can show terms which have Transport. Save the View and you can close it.
Now finally we can edit our content types and add to each a new field of the type Entity Reference with a select list widget. For the target type select Taxonomy term and under Entity Selection choose the following: for Mode, go with Views: filter by entity reference view and then select the View in question - one of the two displays which we created earlier. In the picture below, I named one of the displays

Drupal views 3 - missing "MULTIPLE FIELD SETTINGS" in entity reference

Context: Content type Person has reference (multiple values) to a content type Work, using entity reference.
Need: To display the title of each person node which references a given work, separated by a comma.
Done: A view with a back reference, the right nodes are fetched. (Views 7.x-3.7)
Problem: Cannot display the value separated by a comma. Note: I usually do it with the "Simple separator" display type which is under "Display all values in the same row" in the MULTIPLE FIELD SETTINGS field group. However, this field group is not available in my context.
Solved
I have found the module Views Merge Rows - works very nice. If it does not support Features module for some reason, I can take some of its code code in order to use hook_views_pre_render myself.
I was able to work around this problem by using token_formatters. The basic steps (after token formatters is installed):
No relationship to referenced entity in views (not needed)
Add the entity reference field to the view
Change formatter to "tokenized text"
For 'Text to output' use a token (I'm using [node:field-name])
For 'link destination' use a token ('m using [entity:url:path] for a relative link)
Set multiple field setting as desired
You need a custom views Format here because you are talking about the whole views-row not a multiple results field. You can use the "Unformatted list" and add a comma to be added with CSS or JS.
What kind of Relationship do you use? Can you export your whole views in an external editor and provide a link?
I had a similar issue, where I was using the Entity Reference relationship of "Referencing Entity" instead of "Referenced Entity". (The reference was on the child and the View started at the parent level).
When you run a Drupal System Message on the row (dsm), it returns all the nid responses appropriately, but as different result rows instead of as a single object; however, since the NID field (like many others) has no option for display multiple results, it would only grab the first result.
I ended up having to do an Entity Query from a Views PHP field with the current row's NID as one of the Field Conditions. That seemed to do the trick, rather than trying to load a View inside of a View with views_field_view.
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', '[your_content_type]')
->propertyCondition('status', 1)
->fieldCondition('[your_field_machine_name]', '[field_column_to_check]', $row->nid)
->addMetaData('account', user_load(1)); // Run the query as user 1.
$result = $query->execute();
I had a very similar problem: no "Multiple Field Settings" were available in the field configuration of a multi-value entity reference from my content type to User.
Solved it by removing the entity reference and instead using the multi-value "User ID" field of my content type directly. The "Multiple Field Settings" form area was available now and I selected "Display all values in the same row" there as you do normally. Now this would only display numeric user IDs separated by comma (not desired). But in the field configuration there was also a setting "Format:", which I set to "Label". This would display user names instead.
So I guess by creating a custom formatter you would be able to display your associated "Work" entities in a similar way.

Can I use a node name in a path in a contextual filter?

I can create a view with path "/content/%/relatedarticles", and then create a contextual filter that limits nid to what's passed in "%" in the path. This means that if I go to drupalsite.com/content/1/relatedarticles, I can display all articles related to node 1. I've got this working just fine.
I don't like numbers in URLs, so I'm using aliases. If I have content at drupalsite.com/content/first-node, I want to be able to go to drupalsite.com/content/first-node/relatedarticles and get the same thing as above.
But I can't seem to make this work. The contextual filter validator seems to convert taxonomy terms to ids and user names to ids, but not content names.
Is there some way of making this work?
For Drupal 6 use the Sub-path URL Aliases module, and for Drupal 7 use the Sub-pathauto (Sub-path URL Aliases) module, which is maintained from the same user who maintains the Pathauto module.
You must set validation on to use the taxonomy term in the Contextual filer. Set the filter type to term name converted to tid and check the box Transform Dashes...
The dashes must be addressed to read multi-word URL path segments correctly.
Try to use the node ID (Content: Nid) instead. See this blog post here http://dannyenglander.com/blog/using-views-contextual-filters-create-related-content-block-drupal-7

Drupal VIews Exposed Filter: Taxonomy Select List?

Drupal 6: I have a view (version 2) with an exposed filter on taxonomy term name. The provided exposed widget is a text field with 'Apply' button. What I'm trying to do is to have a drop down populated from a specific vocabulary ('Provinces' vocab consisting of terms 'BC', 'AB', 'SK', etc.), not a free text field.
I thought once I expose the filter I would get the option for a select list, but I don't. All I get is 'Operator (Is equal to, Is not equal to, etc.)' - 'Value (blank field)' - 'optional (check box)'...
I thought that this would be a pretty common thing to do but all my google-ing has found no answer.
Anybody know of a way to do this?
You have to expose the The taxonomy term ID not the The taxonomy term name in order to get the little gear icon so that you can get the drop-down.
I've using better_exposed_filters.
Click settings icon for exposed taxonomy filter and check "Dropdown list"!
just add vocab and terms
there are two areas where you can configure your taxonomy filter. First the "basic" settings, which include all settings you mentioned, and second the settings behind the "gear-icon", where you can chose your vocabbulary and the type of widget.

Drupal Views: Get nodes with the same taxonomy as the current node

I have a Content-Type with taxonomy-terms. It's a select-list, so it can have only one taxonomy - at least of that vocabulary. Now I need to build a view that lists all nodes with the same taxonomy.
Thought that this wouldn't be too hard since it sounds pretty basic. Yet I can't get it working. Any ideas? I'm trying to avoid writing a module for this.
While this was technically possible with Views 2 as described in some of the other answers, Views 3 has this integration built in.
You can create an argument for the taxonomy term id and then choose "Provide default argument". This will then give you an option for "Taxonomy Term ID from URL" and "Load default argument from node page..."
This will allow you to take the taxonomy of a page and pass that as an argument to your view block.
Note: Views 3 is currently in Alpha 3 but in my experience is at a relatively stable state and I am using it on production sites. If it has features like the one above that you find useful please use it, test it and submit bugs/patches if you encounter any issues!
This answer works in Views version 2 or higher. First you need to install Views attach ( http://drupal.org/project/views_attach ). Please read about Views attach before proceeding further. Views attach is best explained by this video http://mustardseedmedia.com/podcast/episode37
Now we get to Views attach. Please enable the views attach module before proceeding. Essentially Views attach attaches a view at the end of the node. In our case our view will be a listing of other articles with the same term.
We will essentially need to "pass" the taxonomy term of the node to the view. Let the name of your Vocabulary be called MyVocab.
Steps to make the view.
Lets call the view display_other_articles_with_same_taxonomy.
Add a display of type Node Content (available after enabling Views attach). This is a display just like block and page displays but with special ability of attaching itself to the node.
Make the following settings in the Node Content Display
Node content settings
Node types: [select the content types you are interested in seeing the list of nodes with same taxonomy term]
Build modes: Teaser, Full node
Arguments: token
Show title: No
You should select Use tokens from the node the view is attached to under Arguments. Let the token be [term-id] This is the "ID of top taxonomy term". This is very important!! Essentially you are going to be passing the taxonomy term of the node from the MyVocab (See http://groups.drupal.org/node/11788#comment-38332). If it has the lowest weight, the taxonomy vocabulary will be the first vocabulary in the taxonomy section of your node edit form. Add an argument Taxonomy: Term Id.
Add the fields you are interested in e.g. Node: Title. Make sure the Node: Title is made into a hyperlink by ticking Link this field to its Node
So what this view is going to do is:
Take the taxonomy term from the MyVocab vocabulary in the Node that is currently being viewed
Pass that as argument to the view display_other_articles_with_same_taxonomy
List all the nodes that have the same taxonomy term as the node being displayed.
Thats it!
If you're using Views 3 (currently at alpha3 at the time of writing) and you want a block (right now the articles have same taxonomy term come at the end of node body) you can do it in the following fashion:
Forget about views attach... its not required
Add a block view. It should contain the same argument, fields and filters as the instructions above for the Node Content display.
You need to modify the settings for the argument Taxononomy: Term Id just slightly: Under Action to take if argument is not present: choose [x] Provide Default Argument. Choose [x] Taxonomy Term ID from URL. Now make sure [] Load default argument from term page is unselected and [x] Load default argument from node page, thats good for related taxonomy blocks. Also [x]Limit terms by vocabulary and choose the Series vocabulary.
Make sure you name the block and put it in the appropriate region.
Note: This answer is subset of the answer I provided at How to just show NodeQueue block on included nodes? In that scenario the requirement was that the related articles are explicitly selected and listed in a particular order. Its a little more complex and uses Nodequeues which we don't need here at all.
Use relationships
Node 1 -> Relationship 1 -> Term // This will be relationships->taxonomy->term
Term -> Relationship 2 -> Node 2 // This will be relationships->node->node
Argument NID to filter NODE 1
Fields or node full view on Relationship 2 (you will see select box on field adding form, to determinate what NODE to use)
Views gives you the options to add filters. Click the plus sign in the filters area of the views admin UI, select Taxonomy from the list, check either Term or ID, and fill in the value that you need to filter by.
EDIT (for explicit instructions):
First, add the necessary fields that you want under the fields section that you want to display from the nodes that you are trying to filter such as node title, etc.
Under Arguments, click the plus sign and select Taxonomy
Check Taxonomy: Term and click Add
Click Update
In your preview area test it out by adding an argument and clicking preview. If it doesn't work, your nodes do not have attached taxonomy, your views module is corrupted, or you didn't follow directions.

Resources