Jump to content
bracketfire

Is there a selector similar to jquery closest?

Recommended Posts

Let's say there's  page structure like

/houses/1-main-st/appliances/dishwasher

And 1-main-st uses a template called House.php and dishwasher uses a template called Appliance.php.

Then let's say I use a selector to get all appliances, say, with an expired warranty.

Then I want to find the house it belongs to.

In jquery, you can use "closest('.house')" for example to locate the encapsulating house.

Is there a way to select the house in PW?  To walk "up" the page hierarchy until I get to the first one with a certain template?

I believe I can easily code one based on a technique shown by Ryan in http://processwire.com/talk/topic/2262-exclude-pages-with-unpublished-parent/?hl=selector#entry21087 but I'd hate to re-invent the wheel.

Sometime when trying to figure out selectors I find an example in these forums that makes me slap my forehead and say "Of Course!  Duh.".

Share this post


Link to post
Share on other sites

No problem, we all were there. This adds another keyword to the index so the next maybe able to find it. ;)

  • Like 1

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...