We have a view, myview
, that is added to the https://www.adomain.com/some-page/
page. It has an exposed filter, Topic
that a person can use to filter the user where Ajax = Enabled
so that it loads the results without refreshing the page.
The view is added to a landing page (content type = basic
) and at the bottom of the page. It is meant to return nodes where topic
tag value is equal to what is supplied from the url.
Taxonomy term values (topic):
- IoT
- Cloud
- Cloud Security
How to setup view to filter based on second URL parameter?
Expected behavior:
- Display all items when
https://www.adomain.com/some-page/
is loaded. - Display all items where
topic = Cloud Security
whenhttps://www.adomain.com/some-page/cloud-security
is loaded - Display all items where
topic = Cloud
whenhttps://www.adomain.com/some-page/cloud
is loaded
Current Behavior:
- Displays all items when loading
https://www.adomain.com/some-page/
- Displays no items when loading
https://www.adomain.com/some-page/cloud
What we have tried using block display type
:
- Create view using
block display type
with a contextual filterContent: topic
When filter value is not available
=Display all results for the specified field
When the filter value is available or a default is provided
is set toSpecify Validation Criteria = enabled
,Validator = Taxonomy Term Name
,Vocabulary = topic
, andAction to take if filter value does not validate = Display all results for the specified field
What we tried using Page display type
:
- add path
/some-path
(without%
) - Add relationship,
field_topic: taxonomy term
andrequire relationship = true
- Add contextual filter:
Name from Taxonomy term (field_topic)
with the following settings below.
Contextual filter settings:
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
Specify validation criteria
=Validator = Taxonomy term name
Vocabulary
=Topic
Transform dashes in URL to spaces in term name filter values
= trueAction to take if filter value does not validate
= Display a summaryCase
= Lower caseCase in path
= lower caseMore
=Transform spaces to dashes in url = enabled
content view
where the results are nodes wheretopic
is equal to the one from the url. If the value is not added to the url then it should return all.