froot Posted August 4, 2020 Share Posted August 4, 2020 I think the pipe-selector should work as OR-operator but it doesn't. It only selects the option before the pipe, not after it. if($q) { $selector = "template=article|blog_post|book, title|body|author*=$q, sort=$getsort, title^=$getletter, limit=25, has_parent!=2"; $matches = pages()->find($selector); } Any ideas? Link to comment Share on other sites More sharing options...
kongondo Posted August 4, 2020 Share Posted August 4, 2020 Your topic says 'pipe selector not working' There are two different uses of pipe selectors in your sample code. template=article|blog_post|book - OR selectors: matching one value or another (docs) title|body|author*=$q - OR selectors, matching one field or another (docs) Which one isn't working? Are you not getting any results or is it returning unwanted results? Are you sure it is not the AND selectors (docs) that are 'interfering'? Perhaps you want OR:groups (docs)? 1 Link to comment Share on other sites More sharing options...
froot Posted August 5, 2020 Author Share Posted August 5, 2020 I did some more investigation and updated the PW-version to ProcessWire 3.0.164 so that I can use the operator ~%= Now it seems to work. However, the issue persists with another page where I use ProFields-Table. $selector = "category=$category, name|text~%=$q, name^=$letter, sort=$getsort"; All the other selectors seem to work fine and search a specific column in the table but as soon as I use pipe it just wouldn't. Link to comment Share on other sites More sharing options...
kongondo Posted August 5, 2020 Share Posted August 5, 2020 47 minutes ago, fruid said: Now it seems to work. Great! Glad you got it sorted. 48 minutes ago, fruid said: but as soon as I use pipe it just wouldn't. Please explain what this means ? Zero? Wrong results? 50 minutes ago, fruid said: where I use ProFields-Table. I'll try and replicate when I get a bit of time. Could you please clarify the field types in your selector? What is category and text? Link to comment Share on other sites More sharing options...
froot Posted August 5, 2020 Author Share Posted August 5, 2020 4 hours ago, kongondo said: Please explain what this means ? Zero? Wrong results? Exactly, I get no results, not for the left nor for the right part of the pipe. column "name" of type is "Tiny Text (up to 255 chars)" column "text" is of type "Text" and column "category" is of type "Select*" The rest are no fields or columns, just additional filters passed to the server via HTML-form with get-method. Thanks for looking into this Link to comment Share on other sites More sharing options...
kongondo Posted August 5, 2020 Share Posted August 5, 2020 1 hour ago, fruid said: column "name" of type is "Tiny Text (up to 255 chars)" Hmm. I've never tried this but I am curious ProcessWire didn't complain about a custom field called 'name'. I would've thought that is a reserved word since ProcessWire pages field has a name column. 1 hour ago, fruid said: column "category" is of type "Select*" Do you mean Select Options field (fieldtype)? Link to comment Share on other sites More sharing options...
froot Posted August 5, 2020 Author Share Posted August 5, 2020 I now renamed the two fields name and text to something more specific but still no success. See attached what I mean by "select*", it's an option field. But there's no issue with that field, just with the two text fields mentioned and the pipe. Link to comment Share on other sites More sharing options...
teppo Posted August 6, 2020 Share Posted August 6, 2020 $selector = "category=$category, name|text~%=$q, name^=$letter, sort=$getsort"; I must say that I'm a bit confused about all this so might've completely misunderstood your point, but just to clarify: "name" and "text" were table column names, not fields on the page? And you're passing this selector to $pages->find() or pages()->find()? If so, you would need to specify them as subfields: "table_field_name.name|table_field_name.text~%=$q, table_field_name.name^=$letter". The point is that now you're referring to the "name" and "text" fields of the page, not the "name" and "text" columns of a specific table field. 1 Link to comment Share on other sites More sharing options...
froot Posted August 6, 2020 Author Share Posted August 6, 2020 in my last post here I said fields, my bad, what I meant is column names inside a ProField table. I use $matches = $page->books("limit=24, $selector"); books being the name of the ProFields Table on this very page. The thing is, it works as long as I don't use a search term, so it looks to me as if passing the selector to the array works fine, except for where I use the pipe. The mentioned category=$category inside the selector is also referring to a column name inside the ProFields Table and I have no issue there. Either column_name~%=$q column_text~%=$q also return results but neither column_name|column_text~%=$q column_text|column_name~%=$q do. Thanks for help Link to comment Share on other sites More sharing options...
kongondo Posted August 6, 2020 Share Posted August 6, 2020 15 minutes ago, fruid said: what I meant is column names inside a ProField table. In that case, what @teppo said should do it (according to the docs in its support board): $pages->find("books.category=something, books.text=$letter"); Link to comment Share on other sites More sharing options...
froot Posted August 6, 2020 Author Share Posted August 6, 2020 $selector = "books.category=$category, limit=24"; $books = $pages->find($selector); tried that now but it also doesn't work. I kept it simple here but I'm getting just one result: echo count($books); // returns 1 and the markup is empty. My guess is it's now counting the columns with that name, not the cells within it? (and that's without even addressing the mentioned pipe-problem.) Link to comment Share on other sites More sharing options...
froot Posted October 16, 2020 Author Share Posted October 16, 2020 any more advice here? This is my archnemesis, I can't get it to work, I tried in so many different ways. Also, while we're at it, never sure how to escape with selectors… for example if I predefine selectors as $selector = "(events.name~%=$q, events.location~%=$q)"; $limit = "limit=24"; and I then include that to select with either… $items = $page->find("$selector, $limit"); $items = $page->find("$selector", "$limit"); $items = $page->find('$selector, $limit'); $items = $page->find('$selector', '$limit'); $items = $page->find($selector, $limit); or should I do… $selector = "events.name~%=$q, events.location~%=$q"; $limit = "limit=24"; and then either… $items = $page->find("($selector), $limit"); $items = $page->find("($selector)", "$limit"); $items = $page->find('($selector), $limit'); $items = $page->find('($selector)', '$limit'); $items = $page->find(($selector), $limit); what about without variables… $items = $page->find("events.name^=a, $limit"); $items = $page->find("events.name^=a", "$limit"); $items = $page->find('events.name^=a, $limit'); $items = $page->find('events.name^=a', '$limit'); $items = $page->find('events.name^=a', $limit); 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