Jump to content

Search the Community

Showing results for tags 'selector'.

  • 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'm trying to create a selector for find() that finds all pages in the site, except the hidden ones. $matches = $pages->find("parent=/"); This works for all except a section I have with a "photos" page as the parent. I use this find() to get the remaining pages. $matches = $pages->find("parent=photos"); I tried several things to combine the two, but nothing worked. Also why doesn't find("parent=/"); find the photo pages also? I guess the photo pages are grandchildren of the root/home page, but is there a way to include them?
  2. Hi all I am having trouble getting some conditional text to appear based on the presence of a child page with a particular template. Based on this thread, I have used this code: $childCount = $page->children("template=studentwork_example"); if ($childCount >= 1) {$example = "<h2>Examples of Student Work</h2> <p>Click on any of the images below to see a full example of Parts A and B of the Challenge.</p>";} else {$example = $nbsp;} The result is that when there is a child page, it looks like this: But when there is no child, the conditional text still displays, like this: Earlier, I also tried this code, with the same result: if ($page->child) {$example = "<h2>Examples of Student Work</h2> <p>Click on any of the images below to see a full example of Parts A and B of the Challenge.</p>";} I have added the template selector in my most recent code example (the first one) because I eventually will have multiple child pages using different templates. My question is: Can someone tell me why my conditional text $example is showing up on all pages using this template, irrespective of whether the page has a child page using the template 'studentwork_example'? Where am I going wrong? Thanks for reading!
  3. Hi, I'm trying to get partial match for fields of type integer, much like how %= and *= selectors works for string. Unfortunately these selectors are not working with numeric fields. Is it possible to do this? For example, if I have pages with control numbers 14975, 91432, 33333, 32414, 13256 I'm looking for something like: $pages->find("controlnumber%=14"); that would match 14975, 91432, and 32414, that would work for numeric fields. Thanks.
  4. I have the following selector: wire("pages")->find("template=news|video, parent|secondary_categories=$page, limit=8, sort=-publish_date, sort=title"); parent represents the parent of the current page $page is the object representing the current page secondary_categories is a field assigned to the "news" and "video" templates, it is of type "Page" and it uses ASMSelect for selecting multiple pages So basically, what I'm telling ProcessWire is: "Get me 8 pages that use either the 'news' OR 'video' template, AND that also have the current $page as their parent OR that have a reference to the current $page within their secondary_categories field". The problematic part is: parent|secondary_categories=$page The OR operator is not working - I'm only getting pages where the parent is $page, and none where $page is in secondary_categories.
  5. Hello, I'd like to sort pages by two selectors. I have a custom field "startdesprojekts" it is of the type date. I want to sort the pages by "startdesprojekts". Since it's possible that there is no date defined I'd like to sort by creation time, if "startdesprojekts" is undefined. My code looks like this, but it doesn't do what I want. $items = $page->children("include=hidden, sort=-modified")->append($pages->find("inNewsAnzeigen=1"))->filter("sort=-startdesprojekts, sort=-created");
  6. hi, i'm kind of „brain blocked“ right now and need your help. i've got a lot (> 1000) articles which have a page field (single page) to reference a category. there are a lot categories, which not all are in use right now. now i need a selector to get only these categories which are referenced by an article. how would you do this? thanks!
  7. Hi, I'm looking for help with my page field selector. I want a field which allows me to select internal pages to link to. I have a strict naming, where all relevant page templates for this case begin with "page-" . So I would love to do something like this: template^=page- but the system tells me this is not allowed. Same for template%=, template*= etc. Edit: I solved it now with a custom php snippet. This works, but maybe there is a more elegant solution? $tmp = new PageArray(); $all = $pages->find('id|has_parent=1'); foreach( $all as $p ) { if( strpos($p->template->name, 'page-') === 0 ) { $tmp->push( $p ); } } return $tmp;
  8. I've created a custom process module, which the user can manage form-entries. In my executeEntries function, I've created a custom InputfieldSelector(should serve as real-time-search) and a custom MarkupAdminDataTable(serves as Resulttable) which holds the entries. How is it possible to combine the InputfieldSelector with the MarkupAdminDataTable? How can I get the selector from the InputfieldSelector? How can I convince the MarkupAdminDataTable, that he uses the new selector from the InputfieldSelector every time when I change the filters in the InputfieldSelector? public function executeEntries: public function executeEntries(){ $this->fuel->breadcrumbs->add(new Breadcrumb('./', 'Event-Manager')); $this->fuel->breadcrumbs->add(new Breadcrumb('./', 'Dashboard')); $this->fuel->set('processHeadline', 'Formulareinträge Event-Formular'); $form = $this->modules->get("InputfieldForm"); $form->method = "post"; $form->attr('id',$this->className()); $fieldset = $this->modules->get("InputfieldFieldset"); $fieldset->label = "Suche"; $fieldset->collapsed = Inputfield::collapsedNo; $field = $this->modules->get("InputfieldSelector"); $field->label = "Filter"; $field->attr("name+id", "filters"); $field->setAttribute("value", "template=50"); $allowedFields = array(); $formtemplate = $this->templates->get("name=form-submission"); foreach ($formtemplate->fields as $fieldN) { $allowedFields[] = $fieldN->name; } array_push($allowedFields, "template"); $field->limitFields = $allowedFields; $fieldset->add($field); $entries = $this->pages->find("template=form-submission"); $table = $this->modules->get("MarkupAdminDataTable"); $table->headerRow( array("Name", "Erstellt", "Aktionen") ); $table->setEncodeEntities(false); $table->action(array('Als Excel exportieren' => "./export")); foreach($entries as $entry){ $data = array( $entry->title, date("d.m.Y H:i:s", $entry->created), "<a href='showentry?id=$entry->id'>Details anzeigen</a> | <a href='./editentry?id=$entry->id'>Bearbeiten</a>", ); $table->row($data); } $preview = $this->modules->get("InputfieldMarkup"); $preview->value .= "<h2>" . $this->_("Formulareinträge Event-Formular") . "</h2>"; $entriesLimit = 20; $entriesOffset = ($this->input->pageNum - 1) * $entriesLimit; $entriesTotal = count($entries); $preview->value .= sprintf($this->_("Anzahl der Einträge: %s"), $entriesTotal); $preview->value .= " | "; $preview->value .= sprintf($this->_("Anzahl pro Seite: %s"), $entriesLimit) . "<br/>"; $preview->value .= $table->render(); $pagination = new PageArray(); $pagination->setTotal($entriesTotal); $pagination->setLimit($entriesLimit); $pagination->setStart($entriesOffset); $preview->value .= $pagination->renderPager(); $form->add($fieldset); $form->add($preview); return $form->render(); } How the Interface looks like:
  9. Is there a way to filter a pagearray you get from the pagetable? As I know something like this wouldn't work because you can't filter pagetable i think? Is there probably an alternative how i coud get this to work: //get all dates of the current acitivty Page from the pagetable where date_from is bigger or equal to today. $filteredPagetable = $page->activity_create_date($selector[e.g "date_from>=today, sort=date_from"]); //check filtered pagetable array & get the latest date from the first item in array. $dateFrom = (count($filteredPagetable)) ? $filteredPagetable->first->date_from : "";
  10. My Code: $lpTitle = strip_tags($thisActivity->Location['name']); $lp = $this->sanitizer->selectorValue($this->pages->get("template=location, title=$lpTitle")); I get this notice: Notice: Trying to get property of non-object in /blabla/blabla/blablabla/site/modules/ProcessXMLImport/ProcessXMLImport.module.php on line 247 Notice: What I am Doing wrong?
  11. Hi all, I wonder if PW allows for a custom sort order of pages? I would like to render my page tree custom sorted for a mobile menu, e.g. not in "reverse sort order" or "sorted by date" and so on but completely customized. My current page tree in the admin looks as follows (numbers are page ids): / |- page 1006 |- page 1058 |- page 1062 But for my mobile menu I try to render the following order: / |- 1062 |- 1006 |- 1058 $entries = $pages->get("id=1|1006|1058|1062, sort=??"); Any ideas how to achieve this? Many thanks!
  12. Hello, in a 2.6.22rc1 install I have a page field "workshops" that selects pages via selector "template=workshop,sort=-dat_start,dat_start>=today)". The field is in a template "anmeldungen". When I edit a page with template "anmeldungen". I can choose pages from the page field "workshops". But when I want to save that page, I get an error Page 2188 is not valid for workshop (Page 2188 does not match findPagesSelector: template=workshop,sort=-dat_start,dat_start>=today) But the workshop I am trying to save to the page field is definitely in the date range >=today. Otherwise it wouldn't be listed in the page field select dropdown. The same error is thrown when I change my selector to "template=workshop,sort=-dat_start,dat_start>=2015-11-04". Also saving pages through the API to that field doesn't work. Only if I omit the dat_start>= selector, I can save pages to the page field.
  13. I have a template called "activity" with two pagetable fields. Fields: activity_create_cast activity_create_date activity_create_cast: uses "cast" template for creating castpages. the cast template contains a pagefield called select_multi_dates. activity_create_date: uses "date" template for creating datepages. the date template contains a pagefield called select_activity. Now what i want is create a cast with activity_create_cast and I want that the selection of the select_multi_dates pagefield should be the pages wich i created before with the activity_create_date. How can I achieve this under the select_multi_dates pagefield with a PHP-Selector? I know its complicated PHP-Selector. Hope you can help me. Thanks for your attention. Nukro
  14. Hello Processwire Community Lets say I have a Multi-User-System where I can create/update as "normal" user new events, dates, multimediapages, imagepages etc.... As Admin I can create organisers(owners) and assign them respectively to specific users. Module for creating/updating pages: Fredi - Friendly Frontend Editor Scenario: Add new Imagepage under Multimedia > Images Important Fields select_organiser(FieldtypePage)(btw. this field is assigned to the user template) PHP-Selector for "select_organiser" if(wire('user')->isSuperuser()){ return $pages->find("template=organiser"); } else{ return $pages->find("template=organiser, id=".wire('user')->select_organiser); } Templates image-index(is assigned to Image-Page) -> Fields: only title - > images-index.php Only show the image pages which has the same organiser like the current user. <?php $out .="<h3>$title verwalten</h3> <div class='span11'> <div class='btn-pos-1 add'>" .$fredi->setText("<i class='fa fa-plus'></i> Bild erfassen")->hideTabs("children|delete|settings")->addPage("image", "title|select_organiser", $pages->get(1153)). "</div> <table id='example' class='row-border' cellspacing='0' width='100%'> <thead> <tr> <th>ID</th> <th>Bildname</th> <th>Bild</th> <th>Beschreibung</th> <th>Veranstalter</th> <th>aktualisiert</th> <th></th> <th></th> </tr> </thead> <tbody>"; if($user->isSuperuser()){ $images = $pages->find("template=image"); } else{ $images = $pages->find("template=image, select_organiser=$user->select_organiser"); } foreach ($images as $i_item) { if($i_item->image){ $thumb = $i_item->image->size(50, 50); } $out .= "<tr> <td>{$i_item->id}</td> <td>{$i_item->title}</td> <td><a class='large_img' href='{$i_item->image->url}' ><img src='{$thumb->url}' /></a></td> <td>{$i_item->image_body}</td> <td>{$i_item->select_organiser->title}</td> <td>".date('Y-m-d', $i_item->modified)."</td> <td><a href='{$i_item->url}'><i class='fa fa-eye'></i></td> <td>".$fredi->setText("<i class='fa fa-pencil'></i>")->renderAll($i_item)."</td> </tr>"; } $out .= " </tbody> </table> </div>"; images(is assinged to children-items of Image-Page) -> Fields: title, image, image_body, select_organiser -> images.php At the beginnnig of the template it checks if the select_organiser of the current user is the same as the select_organiser of the current image page. <?php if($user->select_organiser == $page->select_organiser || $user->isSuperuser()){ $out .= "<h3>{$page->parent->title} Details</h3> <div class='span8'> <table class='detail-view table table-striped table-condensed'>"; $out .= "<tr class='odd'><th>ID</th><td>{$page->id}</td></tr>"; //get all fields: $all_fields = $page->fields; foreach($all_fields as $field){ if($field->type == "FieldtypeImage"){ $out .= "<tr class='odd'><th>{$field->label}</th><td>{$page->get($field->name)->url}</td></tr>"; } else if($field->type == "FieldtypePage"){ $out .= "<tr class='odd'><th>{$field->label}</th><td>{$page->get($field->name)->title}</td></tr>"; } else{ $out .= "<tr class='odd'><th>{$field->label}</th><td>{$page->get($field->name)}</td></tr>"; } } $out .= "<tr class='odd'><th>erstellt</th><td>".date("Y-m-d H:i:s", $page->created)."</td></tr> <tr class='even'><th>aktualisiert</th><td>".date("Y-m-d H:i:s", $page->modified)."</td></tr> </table> </div> <div class='span3'> <div id='sidebar'> <ul class='well nav nav-list' id='yw1'> <li class='nav-header nav-header'>Aktionen</li> <li><a href='{$page->parent->url}'><i class='fa fa-list'></i> Bilder auflisten</a></li> <li>".$fredi->setText("<i class='fa fa-pencil'></i> Bild bearbeiten")->renderAll($page)."</li> </ul> <br /> </div> </div>"; } else{ $session->redirect($error404->url); } The Problem of this System is that the user still can access to image-pages in the backend that dont have the same organiser. Its only view protected. So finally my Question: Can i specifiy a PHP-Selector for the editable pages for the Page Edit Per User Module. Like: return $pages->find("template=images, id=".wire('user')->select_organiser); So that the user can edit the image - pages which has the same organiser like him? Pagetree Structure and some screenshots of the interfaces for visualization: Pagetree Structure: Home(Login-Page) - Dashboard(Intro-Page) -- Events(visible for superuser and user with role: company) -- Agenda/Dates(visible for superuser and user with role: company) -- Multimedia(visible for superuser and user with role: company) --- Images(template: image-index) ---- example-img.jpg(template: image) ... --- Videos -- Profile(visible for superuser and user with role: company) -- Organisers(Only visible for Superuser) --- Organiser-Profiles ---- XYZ AG ... --- Adresses --- Locations -- Settings(Only visible for Superuser) -- Logout Image - Overview Page Image - Detail Page PS: Sorry for the long post
  15. I'm trying to achieve a specific selection for a pagefield for specific users. My pagefield should detect: If the current user is a superuser return all address-pages and when it's not a superuser, return all address-pages which the current user has created. It works fine for the superuser but i have no selection in all the other users. if(wire('user')->isSuperuser()){ return $pages->find("template=address"); } else{ return $pages->find("template=address, created_users_id=wire('user')->id"); }
  16. I have a question on how to group search results by template, with pages sorted alphabetical (as standard) in each group. I have a film blog running ProcessWire. It has lots of posts, ratings, categories, ratings, directors, actors and tags, my search result is getting crowded by all this pages after a while. These pages have different templates. Until now I have had badges with the template label by their title in the search result. I am wondering if there's a simple way of coding it to group the search result, kind of like how IMDb does it: Titles are grouped first, then names second. Like this. To illustrate, here's a part of my structure, template name in brackets: --- Main (home) Blog (posts) Movie 1 (post) Movie 2 Actor (actors) Actor 1 (actor) Actor 2 Director (directors) Director 1 (director) Director 2 Tag (tags) Tag 1 (tag) Tag 2 --- And here's how I would want my search result to show, e.g. if all these pages where to mention Tom Hanks somehow: --- Movies: Movie 1 Movie 2 Directors: Director 1 Director 2 Tags: Tag 1 Tag 2 Actors: Actor 1 Actor 2 --- I am in a learning process, and I am sure there are other problems that will appear when considering usability. Limits within groups, etc. But for now this is a way of sorting that I might also want to use elsewhere later on. Whereas I have headings and results in separate lists. (PS: I have read a couple of posts on group sorting based on parent ID, but none of them was exactly what I was looking for.)
  17. Hi Folks! This is possibly a duplicate but I couldn't find any suitable answer in the forums. I've defined a Page field and tried to restrict the selectable pages using a custom selector. I'd like to whitelist all pages using a template with a name starting with a specific prefix. I've tried the following: template^=some-prefix template.name^=some-prefix But either way it results in a TemplateFile: Operator '^=' is not supported for 'templates_id' error when I'm trying to create a new page using the template that includes this Page field. Am I missing something here? The only workaround I figured out so far is to define the complete list of allowed templates as an OR selector. But this looks pretty awful to me. Thanks in advance!
  18. Hi, I'm sorry if this has been adressed before but I couldn't find anything about it. I'm pretty new to processwire but not to php or object developpment. I'm working on a blog and the request was to add a custom date field on articles that allows the user to override the "date" associated to the article. It's basically a publish date. If set, that date is used to sort the article and also if the date is in the future the article will not be displayed on the website. Here is the selector I used to sort my articles list before: $pages->find('template=news, sort=-created, limit=4'); and here is how I do it now : $pages->find('template=news,!news_date>today, sort=-created|-news_date, limit=4'); The only issue is that the sort does not sort a big mashup of all the dates regardless of whether it's in "created" or "news_date" but it sorts one and then the other. So what I get is a list of dates like this 02 jul 2015 (news_date) 15 Jul 2014 (news_date) 2 Dec 2014 (created) 1 Nov 2014 (created) The news_date list is on top of the created list. Do you know how I could achieve this? Thanks a lot
  19. Was browsing the cheatsheet trying to pickup some new selector tricks and noticed the next all siblings selector. $page->nextAll($selector, $siblings) Introduced in Version 2.0 Description Return all sibling pages after this one, optionally matching a selector. $selector Optional selector string. When specified, will filter the found siblings. $siblings Optional siblings to use instead of the default. Based on the description above, should the following not return a pages siblings? <?php $solutions = $page->nextAll($siblings); foreach ($siblings as $solution){ echo " <a href='{$solution->url}'>{$solution->title}</a> ";} ?> It works if I drop the nextall and refer to siblings without the variable $ <?php $solutions = $page->siblings; foreach ($solutions as $solution){ echo " <a href='{$solution->url}'>{$solution->title}</a> ";} ?> Just curious really.
  20. Hi, I created a Field Type: Page and I want to get a Dropdown where all Pages I have in my PW are listed. With custom Selectors it is possible to call Pages e.g. by template. But in my dropdown I cant select this Page. When I am trying to save I will get an error, that this Page is no valid selection. IMHO it depends on the rule of Parent Page that is selected. Are they any ways to get an Array of all Pages i have, without defining a parent page? Greeting from Nuremberg!
  21. I'm trying to fetch an array of pages that use a certain template with: $my_array = $pages->find("template=xxxx"); But for some reason, it won't return anything for the template that I'm targeting. If I change the template name to my basic page or news templates, for example, I get a list of pages output, but not for the template I want. Is there some setting I've inadvertently set that would cause the template's pages to not display? The template is being used for pages on the site and they display OK as single entry pages. Or could it be related to an issue I had with the same template yesterday where I was adding a new field to the page, and then when I went to edit the page with content in the new field, I'd get returned to the same page I was on, i.e. /processwire/page/edit/?id=XXXX but it would display the 404 template instead? And the data I'd tried to enter wouldn't be saved. The template only has title, multiplier, table and file fields attached to it. And the table field is also modified by the TableCSVImportExport module.
  22. Hi, Is there a way we can make the Selectorfield to choose system templates ? Currently I have created a Selectorfield and added to a template. Now when I create the page, the selector only shows the templates that are not system templates. I would like to show the system templates also in the list if possible.
  23. Hi, We encountered a strange problem regarding the selector behaviour in find()/children(). Background information: Our page setup regarding the templates/fields that go wrong is as follows: Please note that both faq-category and faq-detail are hidden pages, due to the fact that we only wish to display them on faq-overview, not any where else. What's happening: We are using the following selectors to load the faq-categories and within the faq-detail pages. $page->children->find("template=faq-category, include=hidden") Then, for each child of that result, we use the following code: $questionCat->children->find("template=faq-detail, include=hidden") Results from both selector queries are 0 results. If we only use template=faq-category, 14 results (of the 18 pages, a few are unpublished, a few are hidden). If we use the code above, or any variation on it, zero results. None of these work: $page->children->find("template=faq-category, include=hidden") $page->children->find("template=faq-category, include=all") $page->children->find("template=faq-category, status=hidden|published") And now for the strangest part (because I could've just done it wrong, couldn't I): The following code dóes work and returns 16 results (the 14 published ones, 2 hidden ones, and the 2 unpublished ones aren't included, as should be): $pages->find("template=faq-category, status=hidden|published, parent=" . $page->id) $pages->find("template=faq-detail, status=hidden|published, parent=" . $questionCat->id) If anyone is able to give us any insight as of why this is happening and whether it's because we made a mistake (or it's a bug in ProcessWire? Can't imagine but... you never know), that would be great!
  24. Hi there! To allow something as simple as pagination with a little help of $_GET and math. With an additional selector offset, you should be able to get pagination easily done without extra modules. $limit = 10; $offset = $limit * $_GET['page'] - $limit; // page 1 = offset 0, page 2 = offset 10 $posts = $pages->find('template=news, sort=-created, offset='.$offset.' limit='.$limit); So far so good. The only thing missing is the markup: <div class="pagination"> <?php $pagination = $_SERVER["REQUEST_URI"].'?page='; ?> <a href="<?=$pagination.'1'?>">First</a> <!-- numbers --> <?php $amount = count($pages->find('template=news')); while ($i = 1; $i < $amount / $limit; $i ++ { ?> <a href="<?=$pagination.$_GET['page']+$i?>"><?=$i + ($offset / $limit) // 1 + 10/10 = 2 ?></a> <?php } ?> <a href="<?=$pagination.$amount?>">Last</a> </div> Kept very simple so far. But this is only one good example of how to use the offset selector. If there is already something like that implemented, I'd be glad to hear from it! Thanks in advance. Cheers, Martin Muzatko
  25. I am building a search with standard API selectors. Have faced a few confusing moments, so decided to share my experience with it. 1) In the default site profile the search is built with the ~= selector operator like this: $selector = "title|body~=$q, limit=50"; Let's assume that $q = "Process Wire" This does find pages with title or body fields containing both full words Process and Wire (disregarding the case of the letters). It would not find any pages with ProcessWire. That is expected. But if $q = "Process" it still won't find pages with ProcessWire as ~= looks only for full words. This is quite uncomfortable especially for fusional languages like Russian. 2) Nice way to go is to use *= instead like this: $selector = "title|body*=$q, limit=50"; This does find ProcessWire with $q = "Process". But it won't find Pro-Fields with $q = "Pro", as *= uses MySQL fulltext indexes. This index does not index short words (<4 letters or so by default). And the hyphen breaks complex words and makes both split parts index separately (see user comments here). So Pro never gets indexed as it is only 3 letters long. This *= selector operator also does not allow to serch for several separate words as ~= does with its limitations. 3) The slower but more advanced way is to use %= like this: $selector = "title|body%=$q, limit=50"; This would find Pro-Fields with $q = "Pro", but will work slower and still won't be able to search for several words in the same time. I did not find a way to search for several incomplete words in the same time. Seems like it is impossible to achieve with just one selector. Probably I would need to process the search input somehow and build a series of selectors. If someone have already done that I would be delighted to find out how. Good day!
×
×
  • Create New...