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. Hej, i am trying to build a custom PHP code selector to get all pages using a user template for a site using multiple templates for users. Here are my two non-working approaches: /** * A */ return function() { $template_ids = implode("|", $config->userTemplateIDs); return $pages->find("template=$template_ids, include=all"); }; /** * B */ return $pages->find("template=".implode("|", $config->userTemplateIDs).", include=all"); Maybe I am thinking too complicated and I miss something here - basically I need a Page Field which can select from all users with all the different user templates ... uhm - has anyone an idea how this might work? Also in general - has anyone an idea what is actually possible with this custom php code selector? I guess it is somewhat restrained? Thanks! Steffen EDIT: I guess that I can't access $config?
  2. I have an event page were you can select multiple sub-categories with a page field using checkboxes. Now i want to display all the sub-categories but also have them sorted by their parent category. I tried something lik below but that didn't work. $tags = $event_cat->find("sort=$event_cat->parent"); foreach ($tags as $tag){ echo $tag; } Any ideas?
  3. Hello together, I have the following search routine to find pages containing one or more ZIP codes. postleitzahlen.plz is the selector and is a repeater.value The following code works fine and finds all pages that contain the (German) ZIP codes in my test string $p_test $p_test="40489|40822|40878|40880|40882|40883"; $selector = "template=print, title|job_body|job_body_2|job_body_3%=" . implode("|", $suche_1) . "; $selector .= ", id=[postleitzahlen.plz=".$p_test."]"; $matches = $pages->find($selector); My problem is, I do not have 6 numbers in $p_test, I have a lot more. In the worst case scenario I could have around 1500 ! If I have more then 80 numbers in my $p_test I got an error message: Error: Exception: Unknown Selector operator: '' -- was your selector value properly escaped? Is there a limit in having too much selectors? Thanks, Thomas
  4. In reference to http://processwire.com/api/fieldtypes/repeaters/ is it possible to say 'where all repeater items' rather than 'where at least one repeater item' inside your selector? What I have is a repeater with a checkbox. I want to find pages where all repeater items on the page are checked or unchecked. If I do this: $pages->find("my_repeater.my_checkbox>1"); I get pages where at least one repeater item has the checkbox ticked, but what I want is pages where the checkbox is ticked in all of the repeaters.
  5. Hi, I'm having a sorting problem that I need to solve. I have the following code: $today = time(); $trainings = $pages->get('/formacao/')->find("template=training, limit=6, !training_start<$today, sort=training_start"); It's working fine, except for one little problem: I need to show the trainings that have training_start filled first and then the one's that don't. This solution shows the empty ones first! Is there any way to do this with a simple selector? Or do I have to find twice? To understand better: Result that I have now: Footbal: Date not set yet! Ragueby: Date no set yet! Volleyball: 1-Apr-2016 Handball: 5-Apr-2016 Running: 10-Apr-2016 Jumping: 15-Apr-2016 Result needed: Volleyball: 1-Apr-2016 Handball: 5-Apr-2016 Running: 10-Apr-2016 Jumping: 15-Apr-2016 Footbal: Date not set yet! Ragueby: Date no set yet!
  6. Hi Guys, I wanted to find all pages which are children of the current page: $rootPage = $page->children(); But I then want to filter out all pages of a few different templates: $rootPage = $page->children('template!=cta-block|puffs-block|table-block'); But also filter out one specific template called company when the pages website textbox has no value: $rootPage = $page->children('template!=cta-block|puffs-block|table-block')->not('template=company, website='); This doesn't work - I have tried a few different variations, but can't get it right. Anybody point out where I am going wrong? Thanks, Craig
  7. 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?
  8. 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!
  9. 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.
  10. 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.
  11. 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");
  12. 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!
  13. 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;
  14. 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:
  15. 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 : "";
  16. 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?
  17. 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!
  18. 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.
  19. Hello everyone! My first post here. I found Processwire a while ago and have recently been getting to know the system. So far i like it a lot. Right now i'm trying to make a "page"-field where an admin can select and attach users with a specific role. I can get a list of all users, and filter by different fields, but i don't know how to access the roles. As i understand it, selectors can not be used to find user roles, so i wonder if anyone has another approach. I could add a new field to each user with the role names, but that seems a bit awkward. Thanks in advance!
  20. 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
  21. 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
  22. 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"); }
  23. 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.)
  24. 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!
  25. 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.
×
×
  • Create New...