I have a basic page that contains a paragraph which has the following field:
Label = News View
Field Type = Views Reference (reference method = default)

This references a view that has a contextual filter for nodeId. If I set a static value in the paragraph argument (e.g 14), the basic page displays as I want (with the view filtering on NodeId=14).

However, I want this page to filter differently depending on what is in the url (e.g /news/14 or /news/15 etc)

Could anyone please tell me how to do that?

What I am actually trying to achieve (just for reference, not required to solve issue):
A news page that has a paragraph that can be loaded at /news or /news/14. If no number is specified, the page loads the view with no filter. If a number is specified, the page loads the filtered view. The reason I am using paragraphs is that I am actually showing multiple paragraphs each with a different view here, but they all want the same value (or no value) so a solution for one paragraph will suit all.

  • This shouldn't be a problem to configure the contextual filter to use the URL if you don't provide a static value as argument. Unclear though in your question is how you plan to resolve the path, only Views using a page display generate routes. But you could mix different Views display, one to build the main page resolving the path and displaying the basic page and another one to display the filtered result based on a contextual filter pulling the argument from the path. – 4k4 Feb 18 at 9:05
  • Sorry you've lost me with 'only Views using a page display generate routes'. Also, what do you mean by mix different views display? Currently I have 1 basic page with 2 paragraphs in it, and each paragraph shows a different view block. Are you suggesting to build 2 basic pages, 1 for news and one for news/14 (e.g)? – Xzibit Feb 20 at 6:37
  • My comment was trying to clarify things. If you want to display content behind /news you need a route and your question doesn't contain any details how you want to provide one, so I've suggested a View containing a page display. This View would ignore the path and only display a fixed piece of content. Once the path resolves in a route you can place Views blocks on the page which get contextual filters from the path. – 4k4 Feb 20 at 7:33

Your Answer

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

Browse other questions tagged or ask your own question.