Contextual Filter Range Validator adds a Views contextual filter validator that can evaluate a numeric filter value based on user-supplied constraints.
Use Case: Hide or show a view attachment based on a page URL parameter.
The example steps below can be used to display a view attachment on the first page only:
- Create a page view with an attachment.
- Add a contextual filter to the attachment (Attachment -> Advanced -> Contextual Filters -> Add)
- From the “Add contextual filters” popup:
- Select “This attachment (override)” from the For menu.
- Select “Global” from the Category menu.
- Enable the checkbox for the “Null” filter.
- Click Apply (this display).
- Under When the filter value is NOT available, select Provide a default value and set the following options:
- Type: Query parameter
- Query parameter: page
- Fallback value: 0
- Under When the filter value IS available or a default is provided, select Specify validation criteria and set the following options:
- Validator: Range
- Minimum value: (blank)
- Maximum value: 0
- Action to take if filter value does not validate: Hide view
- Click Apply (this display).
- Click Save for the full view.
Once this view is saved, the view page should only show the attachment on the first page because this module’s validator is set to hide the attachment whenever the page URL parameter is not empty (or zero).
Project link
https://www.drupal.org/project/contextual_filter_range_validator
Git instructions
git clone --branch 8.x-1.x https://git.drupal.org/project/contextual_filter_range_validator.git
Comments
Comment #2
raushan commentedHi,
Please make the code to pass pareview:
https://pareview.sh/pareview/https-git.drupal.org-project-contextual_fil...
Please make sure to set the correct default branch: https://www.drupal.org/node/1659588 .
Otherwise it is working fine for me, let the community decide on it.
Thanks
Comment #3
raushan commentedComment #4
wellsUpdates made in d444280 and PAReview shows no more issues. Thanks, @raushan!
Comment #5
avpadernoTo the reviewers: Please set the priority to Normal after reviewing the project.
Comment #6
sleitner commentedAutomated Review
Review of the 8.x-1.x branch (commit d444280):
This automated report was generated with PAReview.sh, your friendly project application review script.
Manual Review
The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.
If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.
This review uses the Project Application Review Template.
Comment #7
avpadernoThank you for your contribution!
I am going to update your account so you can opt into security advisory coverage now.
These are some recommended readings to help with excellent maintainership:
You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
I thank all the dedicated reviewers as well.