0

I have a view with a menu tab link and an attachment, which displays rows of other nodes, depending on the contextual filter.

This view has a custom path(/node/%node/view-custom-path).

How do I show the menu link only when the following conditions are met?

  • The node has some taxonomy terms
  • The view attachment is empty

I have already set the needed term as filter criteria, but the link ignores it and it's shown everywhere. I can display an empty message and send 404 headers when the view is empty, but how can I hide the link as well?

I tried using basic validation in contextual filters and setting Hide view or Show page not found, but that didn't help.

1
  • Have you tried implementing a custom access callback for the route? That's where I'd usually attempt to solve this type of problem. Dec 14, 2021 at 12:13

1 Answer 1

0

First, get the route name of the view. Then, alter that route, giving it a custom access callback that checks required conditions. Deny access if they are not met. Tabs are only shown if/when the user has access to the route.

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.