Inconsistent results with user.subField subselectors when using *= operator

Recommended Posts

abdus    596

I have a template my-template that has a page reference field myUser. The field is set to a user with custom template (using $config->advanced). When I try to filter pages with my-template whose myUser.name or myUser.title includes a certain keyword, I get inconsistent results. Here's what I mean:

// works because tom is an exact match
$pages->find("template=my-template, myUser.name=tom");

// doesnt work even though myUser name is 'tom'
$pages->find("template=my-template, myUser.name*=tom");

// doesnt work despite myUser's title being 'Your Mom'
$pages->find("template=my-template, myUser.title*=tom");

// doesnt work
$pages->find("template=my-template, myUser.title|myUser.name*=tom");

// doesnt work at all
$pages->find("template=my-template, createdUser.name*=tom");

// works
$pages->find("template=my-template, anotherPageField.title*=value");

// works
$pages->find("template=my-template, anotherPageField.title|anotherPageField.body*=value");


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.

  • Similar Content

    • By OLSA
      Hello for all,
      sorry for this topic title but let me try to explain.
      Website has product items, where sometimes products go to "Outlet" (actions/discounts).
      Main part here is that in "action" status:
      a) product can have new price and go alone to discount
      b) product is in group with other products ("collection", and new price is only valid in case when customer buy full collection).

      First problem was how to get this :
      Product items:
      A on action
      B on action in group with "D"
      C  on action
      D on action in group with "B"
      Outlet list page need to show 3 items:
      1. item (A)
      2. item (B, D) (eg. item image is "TV+sofa")
      3. item (C)
      First what I done, was that I created Outlet "category" with children, where children page has fields: title, group image and page select field (to select products from another page tree). But that was wrong and dirty (few foreach, pagination..., etc. that was bad concept).
      Than I decided to place page select field on product item, and from product item select it's group (single select field). And that was ok, and I like it also because administration in any variant need to go to product to set new price. Right now, administration first create group page with some title and with some image. After that, go to product item, check field "action", write new price, and - if - product is part of group - add - it to group.

      There is part of code on "Outlet" list page:
      // outlet-list.php // $items: single items // outlet: page field, it's parent is "Outlet" list page $items = $pages->find('template=product-item, action=1, outlet.count=0'); // outlet=0 or outlet=''... $group_items = $pages->find('template=product-item, action=1, outlet.count>0'); // group items ("merge") foreach( $page->children() as $group ){ // go through Outlet children ("group id pages") if($group_items->has("outlet=$group->id")){ // if in array are items with that group id $group->singles = $group_items->find("outlet=$group->id"); // append to page "group" new attribute and fill it $items->add($group); // now go back and append to "items" new type of "item" } } // pagination $pagination = $items->renderPager(); After it in rendering process I get basic product items, and "group" items together inside list page.
      Here is the problem:
      When I go and set some of Group page as "unpublished", I expect, after it, to get that group subitems shows as alone (singles) inside Outlet. But not.
      They doesn't shows!?
      In that case outlet.count return null, but real "singles" return false. I try more options with selector (and different page select field types) but can't get what expect to be. 
      // selector to return singles 'template=product-item, action=1, outlet.count=0' // tried options outlet=0, outlet='', outlet=0|"", outlet.count<1 etc... Sorry for this long, long topic. If someone has some idea what and where... I would be grateful
      Best regards! 
      p.s. if all this is confused, last sleeping was... can't remember
    • By verdeandrea
      I have pages that have separated fields for first name and last name.
      I'm working on a search form that has one single input field, so that if someone search for "John Doe" it should find all pages that have "first_name = John" and "last_name=Doe" or, of course, "first_name=Doe" and "last_name=John".
      What would be the best use of selectors and operators in this case?
      I came up with
      first_name=John|Doe, last_name=John|Doe so that i should split the search key with |
      I'm not sure this is the best solution.
      What would you suggest?
      Thank you!
    • By webaff
      I want to use language-alternate fields inside selectors for manipulating PageArrays, i.e. find(), sort() or filter().
      I have set up a multi-lingual file upload with the file field "fileField" and its language alternate fields "fileField_lang1", "fileField_lang2", ...
      This works as expected:
      $matches->sort("-fileField.modified"); While this:
      $matches->sort("-fileFile_lang1.modified"); ...throws an error: "Recoverable Fatal Error: Argument 1 passed to ProcessWire\PageArray::getItemPropertyValue() must be an instance of ProcessWire\Wire, boolean given, called in ..."
      Maybe I have to turn off outputFormatting? But how would I do that in this context?
      Any help is well appreciated, thx.
    • By Alxndre'
      I'm trying to sort pages based on their parent's fields, which are page references.
      For instance:
      $someOrders = $pages->find("template=order, sort=parent.customer.id"); Here, order's parent has a template called 'orderslip' that has multiple 'order' children. Orderslip contains a page field called customer, and I want to sort based on the parent's customer's id. But i can't make it work. It throws out an exception:
      Error: Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'customer' in 'order clause' (in /srv/rewwwards/wire/core/PageFinder.php line 410) I'm sure customer page field exists and it works everywhere else. It's just that this time, I'm trying to sort it from a page's 'parent' selector. Is it even possible do this?
      As always, any help is greatly appreciated.  Thanks.
    • By Nils Wiere
      For one of my projects, I'm currently building a small events calendar in ProcessWire. One requirement is that an event may have an unlimited number of associated dates. I tried two approaches, however each approach come with a difficulty:
      1) One page per event with a repeater that holds the dates.
      Page: Event 1
      Text fields for shared event info Repeater with a date field (e.g. Jan 1, Feb 1, ...) Page: Event 2
      Text fields for shared event info Repeater with a date field (e.g. Jan 10, Jan 11., ...) Problem: How can I get a chronological list with all events (dates + shared info) that is sorted like that:
      Jan 1, Event 1 info Jan 10, Event 2 info Jan 11, Event 2 info Feb 1, Event 1 info ... I know how to access repeaters, however all I got so far is a list structured like that:
      Event 1 info
      Jan 1 Feb 1 Event 2 info
      Jan 10 Jan 11  
      2) A page with a page reference field from which the backend user shall be able to directly create child pages for each associated date.
      Problem: What selector string do I need in the page reference setup, to make sure the new page is always created as child of the current page (no matter where that page lives in the backend structure)? Or is this only possible with custom PHP code in ready.php?
      Would you consider one of those approaches a good strategy? If so, do you have any solution to my problems? If not, is there a better way?