yesjoar Posted April 2, 2014 Posted April 2, 2014 Hey there, a little question. I have three fields for the template project: customer, service, business. Now I go to a project and want to show more projects on the given value. So I want to say: Give me all projects, which have customer=$page->customer or service=$page->service or business=$page->business. The comma is the AND selector. But is there a possibility to set an OR selector between more fields? Thanks for your input! Kai.
DaveP Posted April 2, 2014 Posted April 2, 2014 (edited) Something like this should work... redacted due to non-functionality and a wish not to confuse those looking for working code Untested but should work. There may be quicker/easier way(s). There often are. Anyone? Edited April 2, 2014 by DaveP 1
yesjoar Posted April 2, 2014 Author Posted April 2, 2014 Seems there is a problem with the array merging. The variables $customer_merched, $service_merched and $business_merched alone, but after the merching the result is empty… Any other suggestions? Thanks DaveP!
teppo Posted April 2, 2014 Posted April 2, 2014 $pages->find(..) returns PageArray, not regular array, hence the issue with array_merge(). Also there's no need for array_unique() (should it work), PW handles this already by grouping results by page ID's. Apart from that, I believe that DaveP is right; you'll have to do separate queries and merge results: $ps = $pages->find("customer=$page->customer"); $ps->add($pages->find("service=$page->service")); $ps->add($pages->find("business=$page->business")); // etc. One problem with this approach is that, depending on your situation, you might not be able to use limits and built-in pager functions to full extent. Anyway, hope this helps a bit.
apeisa Posted April 2, 2014 Posted April 2, 2014 Totally untested, but how about: business|service|customer={$page->customer}|{$page->service}|{$page->business} 3
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