Jump to content

Search the Community

Showing results for tags 'selectors'.

  • 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

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

  1. 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");
  2. 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
  3. 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!
  4. 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.
  5. 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.
  6. 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?
  7. 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
  8. 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
  9. 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.
  10. 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);
  11. 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?
  12. 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?
  13. 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.
  14. 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?
  15. 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.
  16. 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
  17. 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!
  18. $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?
  19. 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.
  20. 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
  21. 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
  22. 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
  23. Hi! I've read the selectors documentation but I can't find how to deal with a situation where you need to do something like this, but with PW pages: SELECT * FROM products WHERE product_name = 'Computer' OR product_category = 'Electronics' There are 2 OR operators documented, "matching one field or another" ("field1|field2=value") and "matching more than one value in the same field" ("field=value1|value2"), but none of them can do what I need. I tried something like this: "field1=value1|field2=value2", but of course it didn't work. I know I could filter the resulting array, but I would be pulling unwanted data from the db and it would break the pagination system.
  24. I have a processwire dev site, running 2.4.8, and I can no longer access users...When i go to access users, i get this error, and no users displayed: Unknown Selector operator: '' -- was your selector value properly escaped? with debug turned on TemplateFile: Unknown Selector operator: '' -- was your selector value properly escaped? field='roles', value='', selector: 'roles' (and another ~70 rows of errors..) Spent a few hours looking at the database and comparing it with another PW database to see if there is something amiss, but can't seem to track down this problem; the problem may have started after attempting to import some pages with page migrator- i'm thinking that something setting or part of the database got corrupted...? TIA
  25. hi there! I started with the basic PW template and now I have this site tree, it has the categories (apartments, houses etc...) then I have pages that will work as option for the articles, these options are presented in the article as a select input field type. For example objective field name is called option_objective in my article template. root Properties (articles-list-all) - Apartments (articles-parent) -- apartment one (article) -- apartment two - Houses -- house one -- house two Objective (options-template) - Sell - Rent Type of deal (options-template) - Commercial property - Private property Other options (options-template) - other option one ----------------------------------- Page name (template name) To filter and render the results similar to skyscraper's site profile I looked at how selectors work and also at the skycrapper and Macrura's from the speaker's shop example. I can generate the options to select input fields in the frontend but I can't generate the results page. The following is a part of what I have at the moment. I have this part to generate one of the article's option in the search_form.php <option value=''>Any</option> <?php foreach($pages->get("/objective/")->children("id!=1594") as $objective) { $selected = $objective->id == $input->whitelist->objective ? " selected='selected' " : ''; echo "<option$selected value='{$objective->id}'>{$objective->title}</option>"; } Part of the search_results.php $matches = $pages->find("template=article, title|body|objective~=$q, limit=20"); $count = count($matches); echo $out; Thanks in advance for the help.
×
×
  • Create New...