Drupal 7-Views Taxonomy Parent Child URL - drupal-7

Facing an issue with getting views to generate a proper URL similar to the way taxonomy allows me to click on a child term with the path: domain/term/artwork/mirrors (path alias is configured)
Vocabulary:
Product sections
- Artwork
-- Hand Painted
-- Mirrors
- Novelty
-- Ceramic Mugs
-- Stickers
-- Books
- Wearables
-- Shirts
-- Shoes
-- Personalized Shoes
I currently have a taxonomy view with 2 contextual filters: Content: Has taxonomy term ID (with depth) AND Content: Has taxonomy term ID depth modifier
Content: Has taxonomy term ID (with depth) is configured with...
• Depth: 1
• Set the breadcrumb for the term parents
• Display contents of "No results found"
• Specify validation criteria - Taxonomy Term from 'Product Category' vocabulary.
• Filter Value Type: Term name converte to Term ID
• Check Transform dashes in URL to spaces in term name filter values
Page Path: /category/%
With my current setup, I can go to: domain/category/artwork and this displays all content which is categorized under artwork (hand painted and mirrors)
What i need is domain/category/artwork/hand-painted but it displays all artwork regardless if its hand painted or mirrors.
BUT this path, domain/category/hand-painted works correctly. How do i make the url respect the parent term. It seems like views cant interpret a parent - child relationship.
I plan on creating parent term pages outside of this view so the parent term path /category/artwork won't be handled here.
Last thing to note is the node path pattern:
category/[node:field-category:parents:join:/]/[node:field-category:name]/[node:title]
• domain/category/artwork/hand-painted/fancy-painting

I solved my problem by adding the Taxonomy Views Integration module and specifying my existing view page.
-https://www.drupal.org/project/tvi
Next I had to modify the contextual filter to only have 'Basic Validation' and also remove "%" from the page view path.
Now the URL's are exactly what core taxonomy builds but it outputs the view i created
Hope this helps someone else! :-)

Related

How to set taxonomy terms' meta tags in drupal, to display relevant nodes' title in the description meta tag

I have a drupal site and i use some taxonomy terms.
I use these taxonomy term pages to display those nodes having the relevant term.
As an example I have a taxonomy term Cars and in /cars page, are being displayed the nodes with term car.
Like Audi-BWM-Ford.
I need to configure - taxonomy terms pages- meta tags, and i need in the description meta tag area displaying the nodes' titles of each term.
Is there a specific token that can do that? Or any other way?
Drupal nodes are content objects, they are not supposed to be used to display meta informations for taxonomy terms.
If you really want it this way, you'll have to write some code.
I suggest you take a loot at this module: https://www.drupal.org/project/metatag
You'll learn how to assign metadata to taxonomy term pages
Then, you'll have to query you database to retrieve your node titles and set them as a meta.
For most cases metatag module should be enough.

How to display results tagged with just one term ID when there are multiple filters

I have a blog in Drupal 7 and used Views to display the fields. I have 2 sets of tags displayed on the sidebar:
1) SHAPES
Triangle
Square
Rectangle
2) COLOR
Red
Blue
Green
I created the 2 groups of tags via Structure > Taxonomy > Vocabulary > Add Term
For the View, I created one View with two exposed filters (similar to what was done in this tutorial)
VIEW:
Path: '/blog/tag'
Filter Criteria:
1) 'Content: Shape (exposed)'
Exposed form in Block: 'Yes'
Filter identifier: 'shape_id'
2) 'Content: Color (exposed)'
Exposed form in Block: 'Yes'
Filter identifier: 'color_id'
Exposed form style: BEF
The exposed filters are set to the appropriate block region in Structure > Blocks.
If I click 'triangle', only blog posts tagged with 'triangle' should be displayed. Then if I click 'red', only posts tagged with 'red' should be displayed.
It looks like the correct blog posts are being displayed when I click on the terms. The URL gets appended with IDs from both vocabularies, but I can't seem to get the right combos to display.
Desired URL when 'triangle' is clicked: '/blog/tag/?shape_id=1&color_id=All'
Desired URL when 'red' is clicked: '/blog/tag/?shape_id=All&color_id=1'
So, essentially the results should display items tagged with just one term ID.
However, how it is currently working is that if I click 'triangle', and then 'red', both 'triangle' and 'red' have the 'selected' class (are both bolded) and the url is: '/blog/tag/?shape_id=1&color_id=1'
The only way I was able to get the desired URLs is if I have the '-Any-' option displayed. However, the use case I have is to NOT have '-Any-' listed in the list of tags.
Is this even possible without '-Any-' listed in the list of terms? I have never used multiple exposed filters before, so any guidance would be great as I've researched this for almost a week now. I read in another post that contextual filters would allow me to create separate path aliases that are clean urls, but I have not been successfully able to do this.
Any help would be greatly appreciated. Thank you for your time.
I tried using the taxonomy term pages approach, but could not figure out how to get the fields displaying properly. The fields displayed were based on the teaser in my Blog content type. And using exposed filter option was not a solution since my use case was to only display results based on one tag. What worked for me:
1) Add new view to existing Blog View
2) FORMAT: 'Unformatted list'
SHOW: 'Fields'
3) FIELDS: [add fields that you need displayed]
4) FILTER CRITERIA: 'Content: Published (Yes)'; 'Content: Type (= Blog)'
5) PATH: '/blog/[YOUR VOCABULARY NAME]/%'
6) CONTEXTUAL FILTERS: 'Content: Has Taxonomy Term ID'
WHEN THE FILTER VALUE IS NOT IN THE URL: 'Display all results for the specified field'
WHEN THE FILTER VALUE IS IN THE URL OR A DEFAULT IS PROVIDED: select 'Override title' and in the input field, enter: '[YOUR VOCABULARY NAME]/%1'
select 'Specify validation criteria'
Validator drop-down, select 'Taxonomy Term'
Vocabularies: select appropriate Vocabulary name
Filter value type drop-down: 'Term name converted to term ID'
select 'Transform dashes in URL to spaces in term name filter values'
Action to take if filter value does not validate: select appropriate one that works for your needs (in my case: 'Display contents of "No Results found"')
If you need to display the term name in the heading on the results page, in the same view > HEADER > Add 'Global: Unfiltered Text' > then in text area, add something like "VIEWING RESULTS FOR [YOUR VOCABULARY NAME] / %1"
Save the View. Since I had multiple filters, I cloned the above view and renamed everything. So, I ended up adding 3 additional views to my existing Blog View.
I had previously set URL aliases for Taxonomy Term Paths, so I removed these
Also, I had to go back to my Taxonomy Terms individually and delete the URL alias that was generated from the pattern
To have the list of tags displaying on the right with the desired URL structure of /blog/[YOUR VOCABULARY NAME]/[YOUR TERM NAME], I created a separate new view:
SHOW: 'Taxonomy Terms' of type '[YOUR VOCABULARY NAME]'
Create a Block
'Unformatted list' of 'Fields'
FIELDS: 'Taxonomy: Term Name' > click this and unselect 'Link this field to its taxonomy term page'. Then expand "Rewrite Results" section and select 'Output this field as a link' > in the Link path: 'blog/[YOUR VOCABULARY NAME]/[name]' (the [name] at the end of the url structure should appear as you see it with the square brackets) > select 'Replace spaces with dashes' > Transform the case to 'lower case' > click Apply
FILTER CRITERIA: 'Taxonomy vocabulary: Machine Name (= [YOUR VOCABULARY NAME])'
Save the View
Then in Structure > Blocks, place the block in the appropriate region
Hope this helps someone!

Changing default "Taxonomy term" view to add a filter and change path in Drupal 7

I am trying to do a seemingly simple thing but unable to come up with anything.
I'll be specific here for what I want to achieve. I want to clone the existing Taxonomy term which has a path of /taxonomy/term/%. After cloning this view, I wanna make the following changes to it:-
Change the name to Document of Taxonomy Term
Add a filter to this view of a field called is_document. It's a checkbox which is when clicked shows that this node of my taxonomy term is a document.
Change path to /taxonomy/term/documents/%, which shows that I am opening all nodes of this term which are marked as document.
Now when I open my site, let's say with the URL www.mysite.com/organisation/company/documents, it doesn't pick the view. The URL www.mysite.com/organisation/company works as it picks the default Drupal View.
Any idea what I can do here?
I hope I was able to explain efficiently.
UPDATE
I used TVI, but it changes all the pages of my taxonomy terms. I don't wanna change my current scenario where normal taxonomy term pages are opened through /taxonomy/term/% (native Drupal view). I just wanna open all taxonomy terms with a document filter when /taxonomy/term/documents/% view is selected.
Thanks.
I suggest you to download and install Pathauto for URL aliases patterns.
In your Views, you set the path at: taxonomy/term/documents/%
In Pathauto settings, you to go "Patterns", then scroll to the taxonomy section where you can set a new URL pattern: [term:vocabulary]/[term:name]/documents
Then, go to Update tab and update all the paths for Taxonomy.
Enjoy your new Views.

Drupal 7 Views: display tagged content where the url is equal to a taxonomy term

I am having trouble wrapping my head around this one.
I have a taxonomy vocabulary called "industry" with various terms.
I also have a content type called "customers". For each customer I have tagged them with the relevant industry term.
I am trying to create a view that will check the url and if a term from the vocabulary is present, display all relevant customers.
So if the url is: categories/industry-group/insurance
Then the view should show all insurance customers.
I am guessing this has to be done by combining Contextual Filters and Relationships but I can't figure out how.
Update1 1:
Under fields i have:
- content
- Taxonomy Term: ID
- Taxonomy Term: Name
Under Contextual Filters:
- Content has taxonomy term ID (here I am using the raw url and using the 3rd parameter)
Under Relationship:
- Entity reference: industry
The hardest lesson for me to learn is always the same one: patience and reading go a long way.
I figured this out.
Under contextual filters I needed "taxonomy term: name"

Drupal 7 taxonomy root terms view display

I currently have a taxonomy setup like so using Drupal 7:
-root1
--child1
--child2
-root2
--child3
--child4
Something like a country state/province hierarchy.
What I would like to do is create a view for the different terms based on the parent id. So if a user clicks on root1 you would see child1 and child2. Now I've currently have this setup using a page view and using a Configure contextual filter: Taxonomy term: Parent term.
Here's my problem, how do I display the root terms? Basically I want to pass nothing in and maybe somehow setup a default value so that root1 and root2 are displayed on the page.
Current settings:
WHEN THE FILTER VALUE IS IN THE URL OR A DEFAULT IS PROVIDED
Specify validation criteria
Validation: Taxonomy Term
Filter value type: Term name converted to Term ID
I've also tried setting it up as a Term ID only and setting a default value of 0 hoping this would grab any terms with the parent ID of 0 but nothing displays.
This problem in D6 could be resolved easily using Hierchical Select. But the HS module is not fully ported yet.
The issue page about the hs_views submodule:
http://drupal.org/node/1170192

Resources