0

I'm using Drupal 7 as a document management system and I've got a taxonomy vocabulary called "Document Tags" with the following structure:

Accounting
  Best Practices
  Client 1
  Client 2
HR
  Forms
  Policies
IT
Office Management
   Photos
   Org Charts

I created a block view using Views Tree and set up the tree structure that works well so that the categories are nested and expand properly, and are each linked like so:

mysite.com/docs/accounting
mysite.com/docs/accounting/best-practices
mysite.com/docs/accounting/client-1
mysite.com/docs/hr
mysite.com/docs/hr/forms

My document view uses the contextual filter "Content: Has taxonomy term ID" and then in the filter as shown. When I click on a first level category (Accounting, HR, IT, Office Management, etc.) it works great but anything underneath only displays the documents tagged with the top level, so it's evidently only using the first parameter in the display.

Is there a way to have the filter always pull the last URL parameter (e.g. "forms" in the URL mysite.com/docs/hr/forms)?

UPDATED - here are screenshots of the two pages and their results: http://tentenstudios.com/storage/page_1_filter.png http://tentenstudios.com/storage/page_1_results.png http://tentenstudios.com/storage/page_2_filter.png http://tentenstudios.com/storage/page_2_results.png

0

Yes, you can add a separate block with the same settings and in the contextual filter get form from the url.

Add the blocks in the same region and in the visibility settings select Only the listed pages and add docs/*/* for child terms and to the other block add docs/* for the parent terms.

UPDATED:

If you have a Taxonomy type page view then you can do the following thing.

Create and set page view

Create tow pages with path as docs/* for parent terms and docs// for child terms i.e. form.

In the contextual filter add term id and select This Page override. and check Provide default value. In the Type drop-down select Raw value from URL and then from Path select 3 for docs/%/% path and 2 for docs/% path.

Cotextual filter changes.

  • I'm not sure I follow - the documents view is a page view, not a block view (with the URL mysite.com/docs) and if I duplicate the view I don't get how to target just the last parameter. The block view which displays the directory tree works great. – Sean Cunningham Oct 5 '17 at 13:45
  • what is the path for you assigned to this page view. I suppose it is docs/%. – Shrikant D Oct 6 '17 at 5:05
  • I am assuming the path for your site is mysite.com – Shrikant D Oct 6 '17 at 5:44
  • Thanks for the update - unfortunately after making that change the result is the same. I created multiple page views, the first being docs/%, then docs/%/% and set the parameters as described. When I browse to mysite.com/docs/accounting (for example) I get the appropriate results. When I browse to mysite.com/docs/accounting/client I still get everything from the first query. – Sean Cunningham Oct 9 '17 at 18:23
  • Did you checked the overriden dropdown in contextual filters for both views. It shoud say This Page(Override) instead of All Display. Try to check the page with term id as docs/[term_id_for_accounting]/[term_id_for_client]. It should work. After making these changes please make sure to clear drupal cache. – Shrikant D Oct 10 '17 at 9:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.