elabx Posted November 16, 2017 Share Posted November 16, 2017 Hi! I am working on a real estate site and I will create variations of each listing as child of each listing (with the exact same fields) and combine the information in the frontend. Question is, how I could leverage searching fields in the listing AND variations but, I wouldn't want to get Pages that are listing variations. How could I account for: Found "4 bathroom" option inside variation, but I only want to retrieve the parent which is the main listing posting page. What occurs to me is: $result = $pages->find(field1=data, field2=data, template=listing|listing_variation); $only_variations = $result->filter("template=listing_variation"); //import only parents, if already present, will not import foreach($only_variations as $variation){ $result->import($variation->parent); } //Remove the pages variations $final_results = $result->not("template=listing"); Think it will work? Would there be a more efficient way? Link to comment Share on other sites More sharing options...
Robin S Posted November 16, 2017 Share Posted November 16, 2017 I think you should be able do this... $result = $pages->find("template=listing, (field1=data, field2=data), (children.field1=data, children.field2=data)"); ...but it's giving me buggy results when using child fields in the selector (works as expected for name and ID). Will do some more testing later and look at filing a GitHub issue. Alternatively consider including the variation pages in a field within the listing page (i.e. Repeater, PageTable or Page Reference field) so you can match their containing page in the selector. Link to comment Share on other sites More sharing options...
elabx Posted November 17, 2017 Author Share Posted November 17, 2017 6 hours ago, Robin S said: I think you should be able do this... $result = $pages->find("template=listing, (field1=data, field2=data), (children.field1=data, children.field2=data)"); ...but it's giving me buggy results when using child fields in the selector (works as expected for name and ID). Will do some more testing later and look at filing a GitHub issue. Alternatively consider including the variation pages in a field within the listing page (i.e. Repeater, PageTable or Page Reference field) so you can match their containing page in the selector. WOAHH children.field that's some awesome selector right there. 6 hours ago, Robin S said: Alternatively consider including the variation pages in a field within the listing page (i.e. Repeater, PageTable or Page Reference field) so you can match their containing page in the selector. $result = $pages->find("template=listing, (field1=data, field2=data), (pagefield.field1=data, pagefield.field2=data)"); Link to comment Share on other sites More sharing options...
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