Jump to content

Search the Community

Showing results for tags 'selector'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • 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


There are no results to display.

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL







Found 94 results

  1. Hello all, this is a real beginner's question, I guess. Got stuck on how to select the nth child of a page. Couldn't find the right selector at the API cheatsheet or am just to stupid to understand them right. Also searched the forum. What I want to achieve is something like $page->child(2nd); I tried $page->child("start=2"); but the script then just stops there without throwing an error. I'm sure that should be pretty simple but have no clue atm. Thanks in advance gerhard
  2. Lister Selector A Process module that uses Lister/ListerPro, but with a selector string input instead of the normal InputfieldSelector filters. Features For power users, typing a selector string is often faster and more intuitive than fiddling with InputfieldSelector. It also lets you copy/paste selector strings that you might be using somewhere else in your code. Allows the Lister rows to be sorted by multiple fields (not possible in Lister/ListerPro) Allows the use of OR-groups (not possible in Lister/ListerPro) If ListerPro is installed you can run ListerPro actions on the listed pages - the available actions are defined in the module config. Bookmarks can be configured in the module config and accessed via the flyout menu for the module page. Usage Type your selector string on the Selector tab. The selector is applied when the "Selector string" field is blurred, so hit Tab when you have finished typing your selector. Unlike Lister/ListerPro, you can't sort results by clicking the column headings. Control the sort within the selector string instead. Superusers can jump to the module config (e.g. to create a bookmark) by clicking the cog icon at the top right of the module interface. The module is mostly intended for use by superusers, because in most cases site editors won't understand the ProcessWire selector string syntax. If you want another role to be able to access Lister Selector then give the role the "lister-selector" permission. Only superusers can define bookmarks because in ProcessWire module config screens are only accessible to superusers. Screenshots Process page Module config (when ListerPro is installed) Advanced If for any reason you want to create dynamic bookmark links to Lister Selector for a given selector you can do that like this: /** @var $pls ProcessListerSelector */ $pls = $modules->get('ProcessListerSelector'); $selector = "template=foo, title%=bar"; $pls_link = $pls->getProcessPage()->url . '?bm=' . $pls->urlSafeBase64Encode($selector); echo "<a href='$pls_link'>My link</a>"; https://github.com/Toutouwai/ProcessListerSelector https://modules.processwire.com/modules/process-lister-selector/
  3. Hello all, using PW 3.0.148 with the regular site profile for a blog, I got an an empty pagination output when I had a Toggle field in the selector. The Toggle Fieldtype was introduced with https://processwire.com/blog/posts/pw-3.0.139/ . The selector resulting in empty pagination: $posts = $pages->find("parent=blog, sort=-date, limit=10, toggle_field=0"); It worked well, when I replaced the Toggle field with a Checkbox field: $posts = $pages->find("parent=blog, sort=-date, limit=10, checkbox_field=0"); So the prerequisites for the pagination to work are given. The settings for the Toggle field were: Formatted value: Integer Label Type: Yes/No Input Type: Toggle buttons Default selected option: No Thanks for any hints!
  4. Hi there, I have a problem constructing a selector that finds all pages that refer to pages with a specific template. I have pages using an event template and I want to show events based on a specific context. In this example I want to filter the results and only show event pages that relate to a specific template (exhibitions) in their page field related_pages. What I tried: $events = $pages->find("template=event, related_pages.template.name=exhibition"); Unfortunately it does not work (0 results). Same with this: $events = $pages->find("template=event, related_pages=[template.name=exhibition]"); At the moment I am helping myself with the following lines, but I have a strong feeling that there is a more efficient solution: $events = $pages->find("template=event"); foreach($events as $event){ if(!count($event->related_pages->find("template=exhibition"))){ $events->remove($event); } } I really hope that one of you can help me out. Thanks in advance! Flo
  5. The selector in the following code included in a template is returning nothing, however if I take out the compId.resultsdate<={$today} bit, it works fine, although obviously not filtered on the date field. $today = strtotime(date('Y-m-d')); $setImages = $pages->find("template=competitionImage, compId={$page->id}, compId.resultsdate<={$today}, compSubject.name=s, imageRating.title=Merit|Honours,check_access=0"); Here's the results of an example from Tracey Debugger templates_id=79, resultsdate<=1587729600, status<2048 SELECT pages.id,pages.parent_id,pages.templates_id FROM `pages` JOIN field_resultsdate AS field_resultsdate ON field_resultsdate.pages_id=pages.id AND (((field_resultsdate.data<='2020-04-25 00:00:00' ) )) WHERE (pages.templates_id=79) AND (pages.status<2048) GROUP BY pages.id Over in my ready.php I have inside a hook that refers directly to the page template that's used for the pages in the page field above: $today = strtotime(date('Y-m-d')) $event->return = $event->pages->find("template=competition,eventEnd>={$today},eventStart<={$today}"); In this case the filtering on date fields (albeit different ones) works fine. Can anyone suggest why the filter on the date subfield of the page field isn't working? Just to confirm, I do have a date value in the field, and it is a date before today. 🙂 The problem may be something blatantly obvious, but I can't for the life of me figure out why the selector is returning no results when I include the date filter.
  6. I have simple page structure: category subcategory simple-product simple-product simple-product simple-product subcategory .... category2 so Im at category page and running $pages->find("template=simple-product, has_parent=$page, limit=8"); and it returns 0 pages but this returns 4 pages $pages->find("template=simple-product, has_parent=$page"); Can someone explain why limit does not work here? EDIT: So I did some tests and it seems that any limit=n where n is >= actual page count that is possible ... selector return 0 results.
  7. Hi, I need a selector to find pages that are using the template "poi" and that are having a page reference to a page with the title "Zoo". The page reference field is called poi_type. How would I do this? I tried this: $poi = $pages->find(template=poi, poi_type.title='Zoo'); But it doesnt work because there is no field poi_type.title. /Jasper
  8. I'm trying to show upcoming calendar posting pages that have an event_start_datetime and an event_end_datetime. The listing should show calendar postings greater than or equal to today (no past events unless it has an event_end_datetime that is within 3 days after today) if the calendar posting has an event_end_datetime and is within 3 days of today it should still show even though the event_start_datetime has passed. Ex. an event that spans Wed-Saturday. If today is Friday, I still want to show the event on my calendar. Here is the code I have tried: $date = date("Y-m-d");// current date $date_start = strtotime( date('Y-m-d') . " 00:00:00"); $date_end = strtotime(date("Y-m-d", strtotime($date)) . " +1 week"); $paginated_calendar_postings = $pages->get("/calendar")->children("template=calendar-posting|community-event,event_start_datetime>=$date_start, event_end_datetime<=$date_end, sort=-event_start_datetime"); But that doesn't return the correct results. I've spent all day searching through the forums, but couldn't find an answer. Any help is appreciated. Also is there anyway to format your selector on multiple lines like this: $paginated_calendar_postings = $pages->get("/calendar")->children( "template=calendar-posting|community-event, event_start_datetime>=$date_start, event_end_datetime<=$date_end, sort=-event_start_datetime"); It would make it easier to read long selectors. When I tried it, it didn't work. I think it even gave the wrong results.
  9. Hello, I have a Page Reference by template radio button field to promote a certain page (only two options), but I'd like to target the page that isn't selected. This would be used dynamically throughout the site. Does anyone know how I could accomplish this? Would I use something like remove() or not()?
  10. Hi there! I'm using some page reference fields to create lists of tags, categories, years, etc.. I'm able to find the pages like so: $pages->find("template=project, {$filter}={$page->title}"); Which dynamically does something like: $pages->find("template=project, tags=Experimental"); Only if the value (the page name, like "Experimental") starts with letters. If it starts with numbers, find returns nothing. Why is this and how can I fix it?
  11. Hi. I want select pages where now between date and end_date or now bigger than date and end_date is empty. I have five tried variants: $start = strtotime(date('Y-m-d') . " 00:00:00"); $results = $page->children("foo=(date<$start,date_end=''),bar=(date<$start,date_end>=$start),sort=-date,limit=12"); $start = strtotime(date('Y-m-d') . " 00:00:00"); $results = $page->children("date<$start,(date_end='',date_end>=$start),sort=-date,limit=12"); $start = strtotime(date('Y-m-d') . " 00:00:00"); $results = $page->children("date_end=''|date_end>=$start,date<$start,sort=-date,limit=12"); $start = strtotime(date('Y-m-d') . " 00:00:00"); $results = $page->children("!date_end|date_end>=$start,date<$start,sort=-date,limit=12"); $start = strtotime(date('Y-m-d') . " 00:00:00"); $results = $page->children("date_end>=$start|!date_end,date<$start,sort=-date,limit=12"); All this variants not worked for me and returned zero results.
  12. I played with the Selectors object and would like to use it for a special use case... That is a custom Selectors object with dummy data converted to an php array to see the structure (Selectors object is a WireArray with "fields" added) Array ( [0] => Array ( [0] => Array ( [field] => seg1 [value] => val1 [not] => [group] => [quote] => [forceMatch] => ) [1] => Array ( [field] => seg2 [value] => val2 [not] => [group] => [quote] => [forceMatch] => ) ) ) But instead of "seg1" the field name is "field" with value "seg1" (= my field name). So I can't search the Selectors WireArray (= custom WireArray with added Selectors objects) with PW "find('seg1=val1')", Is there a way to search with "find()" or build a simple wrapper to make the elements searchable / filterable with find()?
  13. Hello, I'm facing a weird behavior (to me)... Why are these requests not returning the same values ? // Test 01 : not working > returns empty $allPlayers = $pages->find("team=$team"); // Returns the 10 players (1 of them has HP=14, others have HP>15, no players have coma=1) $dangerPlayers = $allPlayers->find("(HP<=15), (coma=1)")->sort("coma, HP"); // Returns nothing ??? // Test 02 : Working as expected $dangerPlayers = $pages->find("parent.name=players, team=$team, (HP<=15), (coma=1)")->sort("coma, HP"); // Returns the low HP player If you can explain this to me, I would appreciate because this is causing me a headache right now 🙂 Thanks !
  14. On a site that lists events, I am using a repeater field 'event_time', which contains two Inputfield Time fields 'event_time_start' and 'event_time_end'. Some events take place multiple times, others just once. Here's an example for the data structure: event1 title: First Event event_time (1): event_time_start: 08:00 event_time_end: 09:00 event2 title: Second Event event_time (1): event_time_start: 08:00 event_time_end: 09:00 event_time (2): event_time_start: 14:00 event_time_end: 18:00 event3 title: Third Event event_time (1): event_time_start: 07:00 event_time_end: 09:30 First, I'd like to generate a list of all events, sorted by event_time_start, with every repeater item added as an actual event (similar to a SQL JOIN clause). The desired output would be: 07:00-09:30 Third Event 08:00-09:00 First Event 08:00-09:00 Second Event 14:00-18:00 Second Event A selector like $pages->find('template=event,event_time.event_time_start!=,sort=event_time.event_time_start'); would only return each event page once: 07:00-09:30 Third Event 08:00-09:00 First Event 08:00-09:00 Second Event without 14:00-18:00 Second Event Is there a possible alteration of the selector to take all different occurrences into account? Also I'd like to filter for events taking place in the morning, using a selector like: $pages->find('template=event,event_time.event_time_start>=06:00,event_time.event_time_start<=12:00,sort=event_time.event_time_start'); However, this would only return each 'event' page, which then contains also the afternoon version of event2. While I have the impression these are rather simple tasks, I struggle finding a selector-based solution to it. In this example on opening times are some similarities, but it does not deal with multiple occurrences. I'd appreciate your ideas to it.
  15. Reference: PW 3.0.111 and uikit3 based site using the Regular-Master profile. I am trying to add a field that provides a dropdown menu but there are no Options or Selector(s) type available - see attached image of field types available. The following reference under the docs does not appear to be applicable any more: https://processwire.com/api/modules/select-options-fieldtype/ I can't see how to achieve this. Any assistance would be appreciated.
  16. Hi guys, Any ideas on how to get all pages of a certain template that have been created this month? I have tried to test for "created" within the selector and combining it with date("m") but I'm not sure how to go about this? My goal is to set invoice numbers combing an autoincrementing value with each invoice that is created within a given month. Any ideas? Thanks
  17. I am trying to filter my $pages with a find($selector method). $matches = $pages->find($selector); and this is an example of what my selector looks like $selector = "include=all, title|body~=$q, limit=50"; In this case, it only searches according to the matching exact words. For example:we search="art", the result="art times","these art",.... Is there any way to search based on the alphabet? For example: we search="ab", the result="absolutely correct","abstract art",....
  18. I understand from the selectors documentation: I have a repeater field `promo_codes` consisting of text field `title` and an integer field `number1`. I'm running a find: $page->promo_codes->find('title=gmtest'); The database column collation is `utf8_general_ci` so I would expect this to work, but it only works when I match the case exactly ("GMTEST"). This is on PW 3.0.42. Any ideas? Is there an exception for finds on repeater fields?
  19. Hi all, today I've run into some strange error when using selectors. The following selector works fine: $pages->find('template=TemplateName, (many|of|different|fields*=Searching), (year=Searching), (year>=1941, year<=1960), author*=unknown, publisher*="two, maybe three words"|unknown|"another two, maybe three words", area*=All'); Whereas this one throws an error: $pages->find('template=TemplateName, (many|of|different|fields*=Searching), (year=Searching), (year>=1941, year<=1960), author*=unknown, publisher*="two, maybe three words"|unknown, area*=All'); The only difference is in publisher field having only two values. The error is Exception: Unknown Selector operator: '' -- was your selector value properly escaped? Additional info: ProcessWire 3.0.62 All values are sanitized using $sanitizer->selectorValue(string) publisher value usually has commas or parenthesis publisher="one, two"|"three, four" works publisher="one, two"|three|"four, five" works publisher="one, two"|five doesn't work publisher=five works The only conclusion I can make is the selector fails when the last value of publisher is a single word. Any thoughts? All help is greatly appreciated! Jan
  20. I have the following page structure Continents Countries Regions I then have pages "walks" which has a multi-select Page Reference field Regions (I've tried using dynamic fields for this but it wasn't accomplishing what I needed) which has the regions listed by country and then the region (continent is more for searching later on so doesn't need to be seen here). I'm trying to get a count of firstly all the walks within a continent, then country, then region but can't seem to figure out the selector for this. Thanks, Heather
  21. Hello, I passed through a lot of documentation about selectors and a few post in the forum but and I did not find my answer so I'll try here :). Question: Is there a way to find pages that have a certain field attached to his template ? Use case: // Site structure Products Computers Computer #1 (has field cached_details) Computer #2 (has field cached_details) Electronics Test #1 Pet Supplies Test #2 (has field cached_details but is empty) // If I want to get all children of page "products" that contains the field "cached_details" I would do something like this // $products => PageArray $results = $products->children("has_field=cached_details"); // or this $results = $products->children("cached_details!=null"); // Expected: $results would contains [Computer #1, Computer #2, Test #2] // Instead I have to do this $results = new PageArray(); foreach($products->children as $child) { if ($child->hasField("cached_details") === true) { $results->add($child); } } Thank you in advance guys :),
  22. Hi all, From my attempts it seems like this is not possible but thought I would raise it here before scrapping the idea and trying something else. I have an importer script reading a third party feed and creating some pages (page_type_A) based on that. It also creates some other pages (page_type_B) which are by default set to unpublished as the third party don't seem to have control over some of the data they send us, so we set them to unpublished so that someone on our end needs to approve them, so far so good. The issue I have encountered is that page_type_A at creation uses the API to set one of its fields to a particular page_type_B, the field is setup as PageSelector. When I look at the database this seems to work fine, but if you go into page_type_A the Page Selector list is always preset to blank? I updated the Page Selector and set the Selector String to use "include=all" which does populate the drop down with all the correct pages but since there all unpublished it never seems to be preselected to the one which is actually saved as in the DB. Hope that makes some sort of sense.
  23. 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?
  24. I'm trying to figure out how to create a selector that will find pages where a certain text field is either empty of unique. I have about 3500 records where the majority of have a specific field which is simply empty, there some records however that will have a certain value filled in this same field and some of these values are the same. I want to only select the first page which is found with this value and exclude the rest of these pages with the same value. Any ideas?
  25. Hi guys, I'd really appreciate some help from you. I am wondering how I would about using the Selector field type within a repeater. It seems kinda bad design to have multiple selectors (e.g. Grid 1, Grid 2, Grid 3) when I could use a repeater for it. Using Ryan's example, I have managed to get my repeater to work foreach($page->grid_repeater as $grids) { echo "<h2>{$grids->grid_type}</h2><p>"; echo " }
  • Create New...