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 came across this earlier <https://processwire.com/talk/topic/5673-how-to-assign-users-to-page-field/?p=65747> and thanks to Soma I worked around it. I just came across it in a different context and forgot and spun my wheels. Unless I'm really misunderstanding, there's a defect in the lack of symmetry between using TypefieldPage in selectors in the $pages->find() vs. PageArray->find() and there should not be. Plainly, the following code should not behave like it does. The find() against the PageArray should return the same result but doesn't in the 1st example using name instead of ID. // a problem with TypefieldPage in selectors $selector = 'tags=plain'; echo "using \$selector : {$selector}\n"; $res = wire('pages')->find( $selector ); echo "using \$pages->find : {$res->count()}\n"; $res1 = $res->find( $selector ); echo "using pageArray->find : {$res1->count()}\n"; // versus $tag = wire('pages')->findOne( 'template=tag,name=plain' ); $selector = "tags={$tag->id}"; echo "using \$selector : {$selector}\n"; $res = wire('pages')->find( $selector ); echo "using \$pages->find : {$res->count()}\n"; $res1 = $res->find( $selector ); echo "using pageArray->find : {$res1->count()}\n"; /* output: using $selector : tags=plain using $pages->find : 1 using pageArray->find : 0 using $selector : tags=1343 using $pages->find : 1 using pageArray->find : 1 */ It's because the find/matches/(filter) methods work differently in Pages than in PageArray. I don't think this should be so. FYI, in this case, I'm building a form where tags can be assigned as a filter. It works well using tag->name if the filtering is against $pages, but not if it's against the results of $pages->find(), which I need because I need 2 layers of filtering. On to using tag->id... Did I mention I freeeekin' loooove pw? I do I do!
  2. Let's say I've got a template with a field of a Page type. This field is set to handle multiple options (PageArray). Now, I want to select all pages using this template, that have specific page set in the PageArray field. Basically, something like this: $pages->find('template=x pagearrayfield.contains=page1') Is this possible? Any hints? Thanks in advance.
  3. Edit: In other news, I've discovered that a foolproof way to find obvious code errors is to post a problem here. Then I immediately see what I did wrong, but can't delete the post... For the record, double quotes in the find, and I used just template instead of $page->template further up the page. --- Hello again, helpful forum members. I am trying to create a complex query, but not having any luck. In this example, I'm looking for pages with a specific template (could have any parent) *and* pages with a specific parent (could have any template). I understand the or operator doesn't work within find yet, so is there a different way to stack and combine queries? I've determined that this way doesn't work: ... $template = $pages->find('template=species'); $children = $pages->find('has_parent=$page'); $windows = $pages->find('id=$template|$children'); ... foreach ($windows as $window) {... Thanks!
  4. Is there something like that available in PW ? I need to filter something in a repeater by its last value. Something like that: repeater.last.field repeater.first.field
  5. Hello, I've a date field with date input format as follows: 'l, j F Y h:i A' I've a code that creates calendar of given month & year. What I need is, I need to find pages having above field and date as per the generated calendar. From Soma's one post on forum for similar problem, I've written following code, but it's giving error $this_date_raw = $list_day."/".date('m')."/".date('Y'); $this_date = date("l, j F Y h:i A", strtotime($this_date_raw)); $day_shows = $pages->find("show_datetime={$this_date}"); foreach ($day_shows as $ds): $calendar.= "<p>{$ds->title}</p>"; endforeach; Error is as follows: Error: Call to a member function find() on a non-object (line 54 of D:\wamp\www\ticketees_site\site\templates\calendar.php) Thanks in advance.
  6. I have some sample pages setup, titles as follows Adams page Anitas page Another page Another page 2 Another page3 These all have parent id 29. I'm trying to get all pages with title starting with "An". So $pgs= $pages->find('parent=29, title^=An'); foreach( $pgs as $p ) echo $p->title This returns Anitas Page, Another Page, Another page 2, and Another page 3, which is correct. Adams Page is not included as it does not start with "An". Cool. PW makes this so easy! However, if I alter the title selector to find page titles starting with just "A": $pgs = $pages->find('parent=29, title^=A'); this weirdly produces Adams Page and Anitas Page. For some reason the other three pages are not returned. What??! Am I missing something obvious with the ^= selector?
  7. Hello, everybody! I've been experimenting with manipulating files through the API recently and I cannot get my selectors to work with Files. I read about subfield selectors but I cannot get the following code to work: $myFile = $page->get("basic_page_file.name=6121970044ELEPHPANT.jpg"); // field basic_page_file is of type "Files". if (!$myFile) echo "Nothing was found"; // does not get displayed echo "File name is " . $myFile->name . "<br />"; // nothing is displayed for '$myFile->name' Actually, neither error nor the name of the file get displayed. So, I am curious as to what the correct way to use subfield selectors with Files is?
  8. I'm building my first site with PW and am absolutely loving it. I've spent a lot of time reading the forums--fantastic community!--but can't seem to find the answer to my question....so here goes. I'm building a website for an art gallery and would like to have a section on the "exhibitions" page called "related news and press." The page hierarchy looks something like this "exhibitions-parent" (not visible) --"picasso exhibit" "news-parent" (not visible) --"Picasso exhibit opens!" --"New book about Picasso's life and times released" "press-parent" (not visible) --"Review of Picasso exhibit in the NYTimes" Children of "news-parent" use the template "news," which contains two relational page fields called "news_artist" and "news_exhibition" Children of "press-parent" use the tamplate "perss," which contains two relational page fields called "press_artist" and "press_exhibition" In my "related news and press" section I'd like to output all news or press items that are linked to either the exhibit or the artist. I know that the "|" can be used in selectors like this: firstname=Mike|Steve What I'd like to do, however, is something like this: $recent_news_and_press = wire("pages")->find("press_exhibition=$exhibition_id | news_exhibition=$exhibition_id | press_artist=$exhibition_artist | news_artist=$exhibition_artist"); I know this is the wrong syntax, as it doesn't work. Is there a way to do this in one find query, or do I need to run all those queries separately, and then combine them into an array? Also, is there a risk of duplicate results when doing this sort of query, and if so does anybody have any advice on that? Thanks so much!
  9. Well, there is the obvious way: if($page->title == "some unwanted title") { echo $page->headline; } else { echo $page->title; } What I'd prefer is: echo $page->get('title!="some unwanted title"|headline'); but that does not work, is there something wrong with it or is it just not supported?
  10. I've created a couple pages that hold nothing more than categories - referenced by portfolio pages. The multi-select page fieldtypes work just fine. Now I'd like to find all pages that have category X. Since most items have more than one category, I need selector operators like %= or *=. But these simply don't work. e.g. $cat = $sanitizer->selectorValue($page->title); // works // none of these work: $p = $pages->find("portfolio_categories*=$cat, template=portfolio, sort=-Project_Date"); $p = $pages->find("portfolio_categories%=$cat, template=portfolio, sort=-Project_Date"); $p = $pages->find("portfolio_categories*=$cat"); produce the error messages I've uploaded as attachment below. Do I have a buggy mySQL version installed? Other basic selector queries (foo=bar) work fine...
  11. Hi all, I'm tweaking a search engine that's built using PW selectors. I'm wondering if there is a way to set the selector to find word fragments, for example the user searches on 'grass seed' and I want to find fields that have the words 'grasses' and 'seeding' (or 'grassy' and 'seeds' for another example). I know I can use the %= selector, but my options there are body%=grass seed or body%=grass|seed, neither of which return just what I want. I could switch to using raw SQL (body LIKE 'grass%' AND body LIKE 'seed%') but I'd rather stick with PW selectors if I can. Thanks!
  12. I will post it here hoping that it is my mistake and it shouldn't be reported as PW issue. I have pages with field "event_datetime" with value similar to: 2013-02-09 19:00 2013-02-10 11:00 2013-02-12 19:00 2013-02-14 19:00 2013-02-15 19:00 2013-02-16 11:00 and code $today = "2013-02-11 21:34"; $rows = $events->find("event_datetime>=$today, limit=3"); in PW2.2.x echo count($rows) will output: 3 in PW2.3 count($rows) is 0 Is it related to the new changes in the Selectors or I have to use another way to do it properly? Thanks in advance.
  13. Hello. I'm really enjoying going into ProcessWire after using Drupal, CodeIgniter and FuelPHP for a while. Anyway my first question is with this bit of code $items = $page->siblings("template=portfolio-item, sort=random, path!={$page->path}"); As you can see, I'm trying to get siblings of the page, excluding current one. But instead it returns ONLY current page, as if there was no exclamation mark in the path selector. What's the problem here? Update: Okay, have found solution here http://processwire.com/talk/topic/1230-limit-siblings-after-removing-page/ Still curious about path selector behaviour though.
  14. Hello, I've tested some selectors on my site and I'm having a little question here. My 'page tree' look like this : /guests /guests/admin/ /guests/admin/Laurence /guests/admin/Le p'tit /guests/admin/Élodie As you can see, I have names with special characters. I'm trying to retrieve the pages for an autocomplete field on the front-end. So far so good, it worked ok, until I notices I had no result for 'l', that's when I added the 'Laurence' page and it worked. So I thought the problem was due to the apostrophe... Anyway, I used the new 'Selector test' module (thanks to the creator!) and noticed something : parent=/guests/41,title*=l >> returns 1 page found : Laurence (Why not 'Le p'tit' ?) parent=/guests/41,title^=l >> returns 1 page found : Laurence parent=/guests/41,title%=l >> returns 3 pages found : Laurence, Le p'tit, Élodie (no apostrophe problem?) And : parent=/guests/41,title$=ie >> returns 1 page found : Élodie parent=/guests/41,title$=die >> returns 0 pages found ? Why not 'Élodie'? So I don't really know what to think... Am I doing something wrong here? Thanks if anyone has time to give me a clue ;-)
  15. Now I look at this I see it makes sense, as we're allowed to simply type the name of a field to use it rather than some "Field = my_field" syntax (lovely PW ) I can see that whitespace could be weird to deal with so it makes sense that it must not be used; to explain this produced an error: $slideshow = $pages->find( "parent=/work/, slideshow_part_of=1, image_special.count>0, slideshow_copy != ''" ); but this was perfect $slideshow = $pages->find( "parent=/work/, slideshow_part_of=1, image_special.count>0, slideshow_copy!=''" ); the difference being the spaces either side of the != in the final test. I am guessing this is stated in the documentation or obvious or something a PHP person would know and that's how I missed it (not great at RTFM, not great at seeing obvious things and not a PHP hero ) Anyway, I just thought I post this in case it helps anyone else out fitting the above description. Totally loving the speed and power of working with PW.
  16. Hello everyone, I am struggling here with a problem for I wish there is a more elegant solution. Picking up the Skyscrapers demo example, if I wanted to list all architects that had any kind of participation on a specific city, what would be the correct process? I can always list all buildings, pick up their architects, store them in a variable and get rid of duplicates, but I am pretty sure PW has a more interesting approach to the problem. Can anyone help me out on this one? Thanks!
  17. I am wandering to find out if it is easy something like: "..., sort=template, ..." or "..., sort=template.name, ..." for sorting the pages by their template name in selectors result. When it will be useful: 1. My clients were asking to display the professors first, then doctors, then students in the paginated staff list. 2. Other clients requested to display products pages first in the site search results. I know I could use two search selectors and to concatenate their PageArrays but it will be more complicated with the pagination. I could use a dropdown with "search in products", "search in site" too.
  18. I would like to sort the results page with - The last 3 inserted pages - The most visited pages for the last three pages inserted I used the following code $yachts = $pages->find("template=newyachts, limit=3, sort=-date"); foreach($yachts as $s) {... The problem is that do not sort them by date... I do not know if you need to add a field "date", or it is generated automatically (as I thought I had read in the API). Instead to select the most visited pages is there a way? Thanks a lot...
  19. One more selector challenge to face: Currently I'm trying to show a list of pages which's common template owns a “confirmed” field set to true or false and a “user” page reference field. I need to select all pages that are confirmed OR owned by the user currently logged in, even if they aren't confirmed. And all this paginated and sorted by creation date. When I'm not totally wrong, there is just “,” as kind of an AND operator, but not OR but for cases like “title|headline=value”. Or did I miss something here?
  20. Currently I'm facing the problem that I need to select pages by a specific relation between two field values. Is it somehow possible to do something like $result = $pages->find('template=something, field1>field2'); as it would be possible to do within an SQL query? If this isn't possible, yet, I would think about ways to implement something like this e.g. by - in case of a string value - checking if the value matches one of the matched pages' field names or - to be sure it is meant to be treated as a field name - by introducing a notation like “field1=self.field2” similar to “children.count”
×
×
  • Create New...