1

We have a News site that displays all news articles on the homepage and subpages that display only those items tagged with a certain Taxonomy term. So for example we have a World News term so going to www.example.net/worldnews will only show those articles with that term. That works great.

Now we have a request to also filter on Book Content type, so that instead of showing just Article Content nodes we want Article and Book. For the Homepage we'd use the same sort of filter that we did for Article, and that works well. However on the subpages, Book parents AND children are showing up. Is there a way to make sure no children ever show up on the subpages ( but of course would still be accessible the usual way from the parent and siblings )? I've played around with Contextual Filters but can't quite get it right.

We do have some module code written that uses this View so it may be that I need to go that route and write some code, but would love to see if a View-only solution is possible.

  • Are you going to give some specific taxonomy term to parent Book pages or Children Book pages or articles? – CodeNext Jul 21 '16 at 5:03
  • Parents will be a specific term AND have a --homepage-- term Children can also have the first specific term but will not have the --homepage-- term – StevenPatz Jul 21 '16 at 14:33
  • So, all Parent Book node will have homepage taxonomy term, right? – CodeNext Jul 21 '16 at 14:41
  • That is correct. – StevenPatz Jul 21 '16 at 20:40
0

This can be done with Normal filter in views.

Following is the configuration of the filter UI, You need to separate the both content type in the filter with OR and in the Content Type: Book page you need to Book: Depth = 1.

enter image description here

Now in the following image you can see the Article and Book page titles, First one without Book: Depth =1, Second one with Book: Depth =1.

enter image description here

Hence, You can see the views fetches the all articles and only parents books page.

  • Oh, Just I realize that, you are using D8. Under D7 impression I did this in D7. But theoretically this is the way you can achieve. I am keeping this Answer, so you can refer this and can do for D8 also. – CodeNext Jul 21 '16 at 10:48
  • I don't have any of those Filter Options in D8. – StevenPatz Jul 21 '16 at 14:31
  • Yes, that is right..:(. After posting comment, I went to try in D8. But to my surprise, I did find nothing to Book in filters or contextual or field..:(. I am not getting why it is not there, even many things are not there in Views in D8. Tried to find but not getting anything. Hence, let this answer be there, so this will be the comparative example to make someone understand, so if someone knows D8 deep, can suggest by observing this answer. But, sure D7 solves your issue and can be as shown above. Hope, someone will put light abt D8. – CodeNext Jul 21 '16 at 14:40

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.