bracketfire Posted January 6, 2014 Posted January 6, 2014 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.".
Soma Posted January 6, 2014 Posted January 6, 2014 http://cheatsheet.processwire.com/?filter=closest&advanced=1 A quick search with google "processwire closest" reveals: http://cheatsheet.processwire.com/page/built-in-methods-reference/page-closest-selector/
bracketfire Posted January 6, 2014 Author Posted January 6, 2014 I just Googled "Total Dumbass" and my picture came up 3
Soma Posted January 6, 2014 Posted January 6, 2014 No problem, we all were there. This adds another keyword to the index so the next maybe able to find it. 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now