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:

  1. Create a page view with an attachment.
  2. Add a contextual filter to the attachment (Attachment -> Advanced -> Contextual Filters -> Add)
  3. 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).
  4. 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
  5. 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
  6. Click Apply (this display).
  7. 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

wells created an issue. See original summary.

raushan’s picture

Hi,

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

raushan’s picture

Status: Needs review » Needs work
wells’s picture

Status: Needs work » Needs review

Updates made in d444280 and PAReview shows no more issues. Thanks, @raushan!

avpaderno’s picture

Priority: Normal » Critical
Issue summary: View changes

To the reviewers: Please set the priority to Normal after reviewing the project.

sleitner’s picture

Priority: Critical » Normal
Status: Needs review » Reviewed & tested by the community

Automated 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

Individual user account
Yes: Follows the guidelines for individual user accounts.
No duplication
Yes: Does not cause module duplication and/or fragmentation
Master Branch
Yes: Follows / No: Does not follow] the guidelines for master branch.
Licensing
Yes: Follows the licensing requirements.
3rd party assets/code
Yes: Followsthe guidelines for 3rd party assets/code.
README.txt/README.md
Yes: Follows the guidelines for in-project documentation and/or the README Template.
Code long/complex enough for review
Yes: Follows the guidelines for project length and complexity.
Secure code
Yes: Meets the security requirements.
Coding style & Drupal API usage
no issues

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.

avpaderno’s picture

Assigned: Unassigned » avpaderno
Status: Reviewed & tested by the community » Fixed

Thank 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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.