Search the Community

Showing results for tags 'selectors'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Found 48 results

  1. I have $select = 'template=post, when<=now, sort=when, '; $results = $pages->find($select); then output the results' data. It works fine without the sort=when. With it, I get this: Error: Exception: SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias: '_sort_when' (in /Applications/AMPPS/www/website/wire/core/PageFinder.php line 384) what is this I have this elsewhere $start = date('Y', $pages->get($select.' sort=when')->getUnformatted('when')); and it works fine, returns the earliest year.
  2. In my search.php template, I am using $selector = "title|body%=$search_term, limit=50"; to find the top 50 search results for the page. I implemented this following this link https://processwire.com/api/selectors/ My question is how does the selector sort its results? Does it look at the number of time the $search_term has occurred in the page or does it start searching from the root page to all the children. Also, will this change if I do not put any limits to the search results?
  3. I'm having trouble with my selectors when using !=. I'm sure I'm making some newbie mistake, but I'm just not sure how to fix it. This code below functions as expected: $results = $pages->find("template=basic-post, limit=1, path=$post1path, sort=-userpubdate"); but this one (the one I actually need) doesn't work: $results = $pages->find("template=basic-post, limit=1, path!=$post1path, sort=-userpubdate"); It results in an internal server error. How should I have phrased it instead? My intent is to find all pages with the basic-post template but excluding that one specific post. In both cases, $post1path = $post1->url; echo $post1path; where $post1path echoes as expected with the path of post1. The variables therefore seem to be working, but I must be making some sort of fundamental newbie error in my page selection. I would appreciate any guidance that anyone can give. I didn't want to use slice() or other things after getting the page array, as I want to be able to use pagination. UPDATE: I *think* I have gotten around the issue by using ID's instead, where $post1id = $post1->id. $results = $pages->find("template=basic-post, limit=1, id!=$post1id, sort=-userpubdate"); And it seems to paginate correctly as far as I can see - I still have to do more testing with a bigger array to be certain, but it's working on my small test array for now. I'm still curious why path!=$post1path did not work, if anyone would like to comment on that for me. But at least there is a solution that, so far at least, seems to work.
  4. 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");
  5. 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 OR 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
  6. Hello! 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!
  7. Hi, 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.
  8. 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.
  9. 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?
  10. This must be simple, however, I couldn't figure out how to do it. I got this structure in the admin tree: Page 1 [Template A] Children 1-1 [Template B] Children 1-2 [Template B] Children 1-3 [Template B] ... Page 2 [Template A] Children 2-1 [Template B] Children 2-2 [Template B] ... Page 3 [Template A] Children 3-1 [Template B] ... What I want in the front end, is this sort order: Children 1-1 Children 1-2 Children 1-3 Children 2-1 Children 2-2 Children 3-1 Plus, the order should depend on the order in the admin tree. So, if I move Page 3 on top of the tree, the children of Page 3 should appear first. I tried this, but the order seemed to be random (without a connection to the order in the admin tree): $pages->find("template=B, sort=sort"); I also tried this, and again I got a random looking order: $pages->find("root.template=A, sort=sort"); Do you have any idea? Thanks, Nils
  11. Hi guys I have a problem with a specific filter/selector I try to achieve. The following filter causes a SQL-Error. This error also appears when I want to sort subfields(options and page fields - multi and single select) in the lister or with the API. Some Infos Processwire Version: 2.7.3 ListerPro Version: 1.0.8 Media Manager: 0.0.6 PHP-Version: 7.0.8-0 UBUNTU 0.16.04.3 MySQL-Version: 5.7.13-0ubuntu0.16.04.2-log - (Ubuntu) I tried changing the sql_mode many times: DEFAULT IS: ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION NO_ENGINE_SUBSTITUTION I tried all above but with minimal effect. When I remove "ONLY_FULL_GROUP_BY" it doesn't cause a SQL-Error but it still can't find the page. Also sorting subfields start working. But everything works fine locally on a fresh blank install with the media manager and listerpro. My local MySQL Version is 5.6.25 and PHP version is 5.6. ----------------------------------------------------------- The Intention why I am asking (last post): ----------------------------------------------------------- Some other Processwire Topics related to sql_modes: I wanted to ask in the forum before I try it on github: https://github.com/processwire/processwire-issues ----------------------------------------------------------- Some related links to sql_modes: http://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_sql_mode http://dev.mysql.com/doc/refman/5.7/en/sql-mode.html https://dev.mysql.com/doc/refman/5.6/en/sql-mode.html Greetings Orkun
  12. If I use batcher to check these selectors template=product,product_code|title|general_text|specification|hints%=12302,include=hidden I get my hidden pages correctly. However if I use this in this code $result = $pages->find("template=product,product_code|title|general_text|specification|hints%=" . $part . ",include=hidden"); I get no results. Any ideas appreciated.
  13. We have a big selector which we have broken down into 3 chunks to return a list of notes (pages) with repeaters as follows. We also allow the user to filter the results. The problem we have is that the page currently takes nearly 10 seconds to process results. Is there anything we can do to improve the performance of this? I wonder if it would be worth bringing the filters into each of the find()s. I assume that caching here wouldn't work due to querystring parameters? $selector = "template=horse-note"; // Notes with unread comments (date order, most recent first) $notes_with_unread_comments = $pages->find("{$selector}, h_notes_comments.count>0, h_notes_comments.{$session->unread_by}>0, sort=h_notes_last_comment"); //echo 'Notes with unread comments ('.count($notes_with_unread_comments).'):<br />'.$notes_with_unread_comments.'<br /><br />'; // Unread notes (date order, most recent first) $notes_unread = $pages->find("{$selector}, {$session->unread_by}>0, sort=h_notes_last_comment"); //echo 'Notes unread ('.count($notes_unread).'):<br />'.$notes_unread.'<br /><br />'; // Read notes in date order (most recent first) that they were either added or that the last comment was made, whichever is most recent. $notes_other = $pages->find("{$selector}, sort=-h_notes_last_comment"); //echo 'Notes other ('.count($notes_other).'):<br />'.$notes_other.'<br /><br />'; // create notes PageArray $notes_total = new PageArray(); $notes_total->add($notes_other); $notes_total->prepend($notes_unread); $notes_total->prepend($notes_with_unread_comments); // FILTER // sanitize inputs $horse = $sanitizer->text($input->get->horse); $category = $sanitizer->int($input->get->category); $from_date = $sanitizer->text($input->get->from_date); $to_date = $sanitizer->text($input->get->to_date); $comments = $sanitizer->int($input->get->comments); // horse name if($horse) { $selector .= ", parent.h_name%=$horse"; } // note category if($category) { $selector .= ", h_notes_category_id=$category"; } // from date if($from_date) { $selector .= ", h_notes_last_comment>=".strtotime("$from_date 00:00:00"); } // to date if($to_date) { $selector .= ", h_notes_last_comment<=".strtotime("$to_date 23:59:59"); } // comments if($comments) { $selector .= ", h_notes_comments.count>0"; } // apply filter if($selector!='template=horse-note') { $notes_total = $notes_total->find($selector); } // slice PageArray according to pageNum $pageNum = $input->pageNum; $limit = 15; $start = ($pageNum-1)*$limit; $notes = $notes_total->slice($start, $limit);
  14. I need some confirming on how find selectors work... I have, for example, a page find selector setup as: parent=/portfolio/, sort=sort, project_location_london=camden, project_location_elsewhere=midlands What this would do is return any children of 'portfolio' that has project_location_london set as camden and project_location_elsewhere set as midlands. What I'm wondering is if it is possible to return any children of 'portfolio' that either have the project_location_london as camden or project_location_elsewhere as midlands, so it would retrieve both?
  15. I know that the Topic title is probably confusing(sry for that ). Let me explain my Question: I have two Filters(Main Filter & Detail Filter) like you can see below. When I click on a main filter it gets bold and will be added to the "Meine Auswahl(my selection)" container below the Filters. When I click on the "X" span inside the "My Selection" Container, the selected Filter gets resetted. Now, what I want to achieve is a ajax Filter which changes the php Selector for the for the $pages->find(). For Example: When I come to that page, the selector for the main and detailfilter should look like this: $branches = $pages->find("template=branch"); // Main Filters <?php $genres = $pages->find("template=genre, select_sparte=''"); ?> //Detailfilters (Returns a NullPage so dont show the Detailfilters when none main filter is selected) When I select for e.g Example Filter 1 it should change to this without a page refresh: <?php $genres = $pages->find("template=genre, select_sparte.title='Example Filter 1'"); ?> So that I get the Detail Filters of Example Filter 1 without a page refresh. Is this even possible? When yes how, can you guys show me a direction?
  16. In this thread https://processwire.com/talk/topic/11754-search-not-working-as-intended/ there is a really nice solution for dealing with 3 letter words in search. However I am having a problem with selectors. $selector .= ", title|body|collection.title|hue.title|pattern.title|pattern_type.title|usage.title~=" . $sanitizer->selectorValue(implode(' ', $parts)); The problem is that if I have, for example, a search that is looking for myfabric (in title or title.collection) yellow (in hue.title) I get zero results. If I do either separately then I get results. So the search is myfabric yellow. It seems to me as if the query is saying IF EITHER OF THESE WORDS are in EITHER title OR title.collection OR hue.title then show results but not if they are in separate fields. I need it to be IF EITHER WORD is in any field. If both words are in one field then I get results as well. Baffled or dense. Any help appreciated.
  17. Hi! I have many pages-childrens of my main page with name=rates and i want to get all the childrens of my rates page by their input field value. My input field is checkbox and i want to get the page if checkbox is checked. Any help?
  18. I'm trying to find all comments for a small group of pages using the API. The pages, in this case, all have the same author. I'm extending ProcessCommentsManager to accomplish this, by adding the following code at line 167 of ProcessCommentsManager.module (inside ___executeList()): $posts = $this->pages->find("template=post,author=" . $this->author); $selector .= ", pages_id=" . $posts; $selector, at this point, has the following value: start=0, limit=10, sort=-created, status=1, pages_id=4287|4304|4307|4314 And then we resume with the existing code at line 168: $comments = $field->type->find($field, $selector); However, I'm only getting comments for page #4287, the first one in the list. I've tried this with several data sets and it's always the same. Is there something about pages_id that doesn't like the usual pipe format for multiple values? Is there a better way to solve this problem? I'd also welcome feedback about whether this is generally a good approach to displaying comments only for certain pages.
  19. Hi, I'm having problems getting a series of images in the same standard images field to sort by date modifed/created. How would I add the ->modified property here to get the images to display in order of date modified/created? if ($page->images) { foreach($page->images as $image) { $thumbnail = $image->size(868,0); echo "<img class='r' src='{$thumbnail->url}'/>"; } } Have tried a few variation with no luck yet : ( thanks Alex
  20. Hi, I'am at a loss ... I was absolutely certain that something like $wireData->has('key=value') or $wireData->is('key=value') existed. But it does not. has only takes a key name not a selector, and is does not exist on WireData. Is there another WireData method I am missing to accomplish this? I know there are simpler ways to get if a field has a certain value, but I need it as a selector string. Thanks!
  21. $pages->get("/stories/")->find("external_status!=accepted"); This selector works as expected, excluding all the story pages that have "accepted" in the external_status field, but it also excludes stories with no external_status defined (field is empty). How can I make sure those pages are included?
  22. hi, in the 2.5 changelog there are some words about the new selector-features: ... what means "(database selectors only at present)"? And for the second point, shouldn`t somethin like this work ... $pages->find("template=address_abo, adrdb_multi.id=[adrdb_location.value=stp, anzahl>0]") // or both together $pages->find("template=address_abo, adrdb_multi.id=[@adrdb_location.value=stp, @anzahl>0]") // ok, had to read "can be used on the 'id' property of any field that maps to a page". // maybe this? $pages->find("template=address_abo, (@adrdb_multi.adrdb_location.id=[value=stp], @adrdb_multi.anzahl>0)") ...trying here to query a reapeater "adrdb_multi" which contains a page-field "adrdb_location" and a textinput "anzahl" which both should be true. thanks, martin.
  23. I found something I'd consider a bug. Let's say we have this very useless hook: $pages->addHookProperty("Page::foo", null, function($event) { $page = $event->object; if ($page->title === "About") { $event->return = "About foo"; } }); When I search for pages with a non empty foo property: $pages->find("foo!=''"); I get an exception: Error: Exception: Field does not exist: foo (in /wire/core/PageFinder.php line 494) Which I consider very IN YOUR FACE to begin with, even if the hooked property foo would not exist. If none of the pages have a field called foo, then just get me ZERO pages. BUT since this property is created via hook, PW should not tell me the field does not exist. However, If I use the same search with a filter it works as expected, I get a PageArray with one result (bc there is one page with the title About): $pages->find("*")->filter("foo!=''"); Please don't tell me this is expected behavior
  24. Hi folks, Firstly... what an incredible CMS. Just been a breath of fresh air and really finding it so powerful. So thanks! Just a quick question. I read on the Inputfield Dependencies docs that OR selectors | aren't supported here yet. This is fine... but is there an alternative or another way to do the example below? I have a Pagefield set up for a 'Members' section, to choose whether the member is a Chair or Vice Chair when adding each children page to this section. If they select 'Chair' OR 'Vice Chair' from the dropdown, I would like a specific field (email address) to be shown. I have done some input dependencies on other fields/templates (show a closing_date field if the news type is 'Job') etc. but have only ever had one dependency to declare. Now I have two, which I know you can separate with a comma, but essentially, it needs to be if either 'Chair' or 'Vice Chair' is selected from the Pagefield dropdown. chair_vice=1062|chair_vice=1063 chair_vice=1062|1063 You see what I mean? Any clues/tips? Or would I need to create two fields here? An email field for Chair and an email field for Vice? Thanks in advance, R
  25. Is it possible to use something like "template.data.altFilename=" in a selector? I could write a long selector with all the template names and alot of ORs but it would be nice to not have to edit the selector when I assign the alternate template file to another template. I am using the All In One Minify module to conditionally load scripts and the condition is a PW selector. But I have a pretty good amount of templates with a single alternate template file. TIA lloop