Jump to content

A tricky selector based on a parent page's checkbox


heldercervantes
 Share

Recommended Posts

Hey guys and gals.

I have a page tree that I want to search, where the second level has an "archived" checkbox. Something like this:

  • Home
    • Products
      • Category ('archived' checkbox field is here) 
        • Product (these also can have subpages that I want to catch too)
        • Product
        • Product 

And now that I'm making the search engine for this site, I want to query all product pages, and I want to sort them showing "non-archived" items first. I suppose there's a way I can incorporate something like 'sort=$page->parents[2]->archived' (not like this of course, but...)

Any ideas?

Link to comment
Share on other sites

I can't find any documentation at this moment that shows this working, and I don't have any sites that come to mind where I could test this, but I think it works... If your search is only searching pages that have a template of 'product' (or whatever your product template is), I believe you can use this:

sort=-parent.archived

This assumes that the value of archived is 1, if it is indeed archived.

  • Like 3
Link to comment
Share on other sites

You could use the Find Merge module and supply it with two selectors: one for products without an archived ancestor and one for products with an archived ancestor. You'd probably start by finding the archived categories, then your selectors would include "has_parent!=$archived" and "has_parent=$archived".

  • Like 4
Link to comment
Share on other sites

16 hours ago, Robin S said:

You could use the Find Merge module and supply it with two selectors: one for products without an archived ancestor and one for products with an archived ancestor. You'd probably start by finding the archived categories, then your selectors would include "has_parent!=$archived" and "has_parent=$archived".

Well, I can just do two searches. I'm just being stubborn assuming there's a straightforward solution for this 😆

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...