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. Hi, I'm trying to setup a page field with a custom selector. Intention is to show only pages of the currently logged in user in the select drop down. Here's what I tried in the field setup: I also tried But I guess this doesn't make a lot of sense because when the page is created and has not been saved yet, the $page->createdUser isn't there yet. I always get an empty select It seems like the page field is not aware of the $user object. Is there any way how I could filter the pages by created_users_id, maybe through a hook on that field?
  2. 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.
  3. 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.
  4. 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!
  5. 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
  6. 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!
  7. Hi there! The title may be a bit misleading, or at least it's how I tried to achieve something which may not be possible in that combination. But let's start from the beginning: I'm trying to create a football team & game manager with processwire. As someone who used Excel in all ways possible to manage every aspect of a football team (members, positions, games, etc.) and having used processwire for solely building websites in the past, I thought this has to work, too. And for the most part it does! Yet, I have a few things which may work even better and that's where I'm stuck. I currently manage: Team members (pages) Game positions (pages) Games (pages) In "games" I have something like "location", "opponent", etc. and I have created a repeater field which includes "team member" (selector from page "team members") and "game position" (selector from "game positions"). I am able to map a "position" to a "team member" for each game. That's fine & well, BUT: it would nice, to have those selector being somehow connected to each other in a way, that if I am selecting a team member and assign him to a position, that this position & member will be deleted from other repeater "selectors". This way I want to prevent a team member or game position to be used n-times in one game. It's just a usability thing, but a big one for me, since I may be not the person working with this in the future. Is this somehow possible? Thank you!
  8. This excludes children of "/example/" (/example/ has id of 1006) $results = $pages->find("title|summary~=$q")->not("has_parent=1006"); … and this will exclude them too $results = $pages->find("title|summary~=$q, has_parent!=/example/"); … but this won't $results = $pages->find("title|summary~=$q")->not("has_parent=/example/"); And … is there any difference using not() and != ?
  9. Hi guys, I have a category template and articles in different category ( articles template ). category1 - articles category2 - articles category3 - articles - articles I am listing all the articles via the selector "template=articles" . When the category is made as unpublished or hidden then also the articles are displaying. Is there a way other than doing $category = $pages->find("template=category"); $category_ids = $category->__toString(); $articles = $pages->find("template=articles, parent=$category_ids"); I can get only the articles for published ones? Thank you
  10. Im working on a sort of "friend request" script for a front end user profile. the user template has the following extra fields of the type Page friend_invite_in friend_invite_out friend_confirmed There will be a ajax post containing the username when pressing a button to send a friend request. Lets say user "A" does a request for user "B" to become friends. The ajax script should handle the post and add the foloowing page references: User "A" will receive a page reference to user "B" in the friend_invite_out field. User "B" will receive a page reference to user "A" in the friend_invite_in field. Then user "B" can confirm, so that the page references are moved in the following manner: User "A" page reference to user "B" will be moved from friend_invite_out field to friend_confirmed field User "B" page reference to user "A" will be moved from friend_invite_in field to friend_confirmed field This i kinda the logic behind the whole process. But to prevent sending clear usernames i would like to have a md5 hash in my HTML/jQuery code. This is no problem to do with PHP. But how would i make a selector that can handle this md5 hash and get the right user? // this does not work! $md5 = $this->input->post->userid; $u = $this->users->get("MD5(name)=$md5"); In MySQL it the query would be something like this (havent tested it) SELECT * FROM users WHERE MD5(name)=$md5
  11. There is template "mytemplate". There is field "myjson" in this template that stores json string. What is the most performance-effective way to check if a given json string already exists in some page using PW selectors? // this code doesn't work due to selector quote issues $query = 'template=mytemplate, myjson=' . $json; if($pages->count($query)!==0) ... // this code doesn't work as sanitized json string is not equal to original json string $query = 'template=mytemplate, myjson=' . $sanitizer->selectorValue($json); if($pages->count($query)!==0) ...
  12. output page filter by roles, output in admin and other areas, all good! on Change select page "Page 1022 is not valid for manager" Custom selector to find selectable pages > roles=manager
  13. I am embarrassed that I have to ask this question, but I cannot get my selector to work. I want to output a list of players that are assigned to their specific team. Each Player has a team_name field which references their team as a page field select drop down. $players = $pages->find("template=player, team_name=$page->id"); foreach ($players as $player) { echo "<li><a href='{$player->url}'>{$player->title}</a></li>"; } $page->id is referencing the team page. I have tried multiple variations using both find/get but I am missing something. Any kick in the head is appreciated. My structure is like so Players -- Player 1 Teams -- Team 1
  14. Hi all, given that "customfield" is unique without spaces and 64 characters long, this returns a null page: $myuser = $users->get("customfield=eebc849774d363186b6ebc4e3bc86a03be2a03b6d4411a4a91b3a70faa4a39b2"); The page/user still exists with that equation ("customfield" is set to "Text" and added to the Users-Template, in Admin the user is shown with the right "customfield". Is there a maximum parameter size for a selector? Regards, Thomas
  15. Hey all, i wonder if there is a way to imitate an IN() statement like "SELECT id WHERE field IN(1023,1208,2357)" I have a website where i have products assigned to categories, and each product can be assigned to multiple categories. The categories are (of course) pages, so the "categories" field of a product might look like "1034|1209|1508". The pages to display the products are also assigned a category (the products are not displayed on the category pages themselves), but this can only be one at a time. What I am trying to do is to find all products of a category and display them on a page... but I can't figure out how to do that. I tried $pages->find('category='.$page->category); but that didn't work, i think due to the fact that each page can have multiple categories. I would need something like $pages->find($page->category.' in category'); or $pages->find('category has '.$page->category); Is there already a way to accomplish this? Or should I use a completely different approach? Any help is appreciated. Thanks!
  16. I've spent few hours at this problem but looks like it needs attention from more qualified people - (1) there is function like this: function save_vehicle($wire, $titles) { $default = $wire->languages->get("default"); // retrieve English $russian = $wire->languages->get("russian"); // retrieve Russian $wire->user->language = $default; // whatever current language is, switch it default (English) $parentpage = $wire->pages->get('/vehicles/'); $selector = 'template=vehicle-category, title="'.$titles[1].'"'; $p = $parentpage->child($selector); // do we already have this category? if(!$p->id) { $p = new Page(); $p->template = 'vehicle-category'; $p->parent = $parentpage; // get parent page $p->of(false); $p->title->setLanguageValue($default, $titles[1]); // set in English $p->title->setLanguageValue($russian, $titles[0]); // set in Russian $p->name = $wire->sanitizer->pageName($titles[1]); $p->save(); // save the page with the two language values } (2) this function is called in a cycle (3) when it is is called first time in a cycle - everything is OK, if creates new page as I expect (4) when it is called second time with same arguments, it produces error in row $p = $parentpage->child($selector); Error: Exception: Unknown column 'field_title.data1439' in 'where clause' (in /share/MD0_DATA/Web/pw/wire/core/Database.php line 118) (5) the strange thing (at least for me) is that when I run this cycle once again - everything is OK, e.g. selector works, script detects that page with such title exists and doesn't create new page. Please help. Thanks in advance!
  17. All: If you saw some of my recent postings where I was trying to solve the problem of running a query as a field, I have solved it. I started with Hanna text, but that didn't quite get me all the way. Then I tried just a Concat field, and that didn't get me all the way. I modified the Concat fieldtype for my solution. I had a need to dynamically pull Pages that were cross-referenced back: Product as a Page Photo Pages with a multi-Page Select field that referenced Product (A photo could represent 1+ Products) I wanted a ->photos field from Product that was updated dynamically according to what Photo entries were currently in place, and I didn't want copy/pasted code, and I wanted the selectors to be easily modifiable from the admin screens. Usage is faily simple: 1: Install as a normal module 2: Create a field as a PagesSelectorQuery type 3: On the field details, enter your selector string, ie: template=my_template,select_page_field=$page 4: Add your field to whichever templates. 5: Access the PageArray results like you would any other $page->field I hope you find it useful, at the very least as an exercise in my madness. Thanks again for all the help this community has provided. EDIT: Added to GitHub: https://github.com/alevinetx/processwire-modules/blob/master/FieldtypePagesSelectorQuery.module And Module's page: http://modules.processwire.com/modules/fieldtype-pages-selector-query/ FieldtypePagesSelectorQuery.module
  18. I feel like I'm getting super lost with all of my questions today I have a Checkbox field, "premium". This field is added to a template, myContent I have 2 pages created with the myContent template. One has premium checked, the other does not. My query is: Show me all Pages using 'myContent' as a template, and whose premium field is not selected (0): selector: template=myContent,premium=0 This query is returning 2 Pages, which is should not. When I iterate through the returned list, I can see ->premium as set 1 for one, 0 for the other. If I change "premium" in the selector to some random value that doesn't exist as a field name, the query runs and still returns 2 Pages. selector: template=myContent,feujfhejhejejhejhefje=0 I would think it should error out, but instead seems to be doing a short-circuit evaluation. Are comma-delimited selectors not "AND"ed together? If I place the premium field at the start, or even by itself selector: premium=0 I get this error: Notice: Uninitialized string offset: 0 in C:\dev\xampp\htdocs\pwire\wire\core\Selector.php on line 49 Fatal error: Exception: Field does not exist: (in C:\dev\xampp\htdocs\pwire\wire\core\PageFinder.php line 248) #0 [internal function]: PageFinder->___getQuery(Object(Selectors)) #1 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(271): call_user_func_array(Array, Array) #2 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(229): Wire->runHooks('getQuery', Array) #3 C:\dev\xampp\htdocs\pwire\wire\core\PageFinder.php(145): Wire->__call('getQuery', Array) #4 C:\dev\xampp\htdocs\pwire\wire\core\PageFinder.php(145): PageFinder->getQuery(Object(Selectors)) #5 C:\dev\xampp\htdocs\pwire\wire\core\Pages.php(144): PageFinder->find(Object(Selectors), Array) #6 [internal function]: Pages->___find('=0') #7 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(271): call_user_func_array(Array, Array) #8 C:\dev\xampp\htdocs\pwire\wire\core\Wire.php(229): Wire->runHooks('find', Array) #9 C:\dev\xampp\htdocs\pwire\site\assets\cache\HannaCode\pages_query.php(3): Wire->__call('find', Array) #10 C:\dev\xampp\htdocs\pwire\site\assets\cache\HannaCode\pages_que in C:\dev\xampp\htdocs\pwire\index.php on line 214 Please point out what I'm doing wrong! Thank you. Again!
  19. This is 2 questions in one post; I hope that's permissable. 1: I'm trying to find a way to create a field whose value is a selector query, and at page time the field runs the query. This is very akin to http://processwire.com/talk/topic/1489-how-to-retrieve-possible-pages-list-in-a-page-field, but reducing code duplication and making it as natural as any other field. The Page input already allows for the query/snippet to provide possible _selections_ at page creation, but not a way to harness that query's results as a field. Am I making sense? I've not started digging in to the fieldtypes, and I see http://processwire.com/talk/topic/4079-input-field-for-dimensions/ may be a good place to start down this path, unless there's a module I missed that already addresses this. 2: I've seen some screenshots where creating a new Page from a template has a nice layout to the field entries. I am aware that you can specify the entry widths during declaration. However, is this an adjust/reload/repeat process to get some fields grouped together on the same line nicely, or is there a way of handling the field entry layout that I'm not aware of? If either of these questions seem addled in thought, it's me, not you. Thanks for any help, input, and advice you may provide!
  20. Hi Everyone, Any help is appreciated. I'm trying to get either current and future events (pages) or past ones and am getting an error. Here's my code ... if ($page->showPastEvents) { $items = $pages->find("template=event, eventStartDate < today, limit=$page->numberOfItemsPerPage, sort=-date"); } else { $items = $pages->find("template=event, eventStartDate >= today, limit=$page->numberOfItemsPerPage, sort=-date"); } I've also tried this: $today = strtotime(date('Y-m-d')); if ($page->showPastEvents) { $items = $pages->find("template=event, eventStartDate < $today, limit=$page->numberOfItemsPerPage, sort=-date"); } else { $items = $pages->find("template=event, eventStartDate >= $today, limit=$page->numberOfItemsPerPage, sort=-date"); } And here's the error I'm getting, thoughts? Error: Exception: Unknown Selector operator: '' -- was your selector value properly escaped? (in /var/www/vhosts/sharespost.com/sharespost.co.v1/wire/core/Selectors.php line 165) #0 /var/www/vhosts/sharespost.com/sharespost.co.v1/wire/core/Selectors.php(190): Selectors->create('eventStartDate', '', '>= 1374033600') #1 /var/www/vhosts/sharespost.com/sharespost.co.v1/wire/core/Selectors.php(63): Selectors->extractString('template=event,...') #2 /var/www/vhosts/sharespost.com/sharespost.co.v1/wire/core/Pages.php(143): Selectors->__construct('template=event,...') #3 [internal function]: Pages->___find('template=event,...') #4 /var/www/vhosts/sharespost.com/sharespost.co.v1/wire/core/Wire.php(271): call_user_func_array(Array, Array) #5 /var/www/vhosts/sharespost.com/sharespost.co.v1/wire/core/Wire.php(229): Wire->runHooks('find', Array) #6 /var/www/vhosts/sharespost.com/sharespost.co.v1/site/templates/basic-page-events.php(12): Wire->__call('find', Array) #7 /var/www/vhosts/sharespost.com/sharespost.co.v1/site/templates
  21. Hi guys, I need a little help on this. I want to be able to add optional categories to pages from a specific template. Main category will be set by the pagetree (parent) and the optional ones will be selectable by pagerefence (type:page). Only I want to exclude the one set by the pagetree (as this one should be set already; will do this by an import). I guess the solution can be done by a custom selector (input fieldsettings), but how? Any help would be greatly appreciated
  22. Hi guys, I'm currently trying to add events to a calendar where each event will have a date as a parent. I'm trying to error check duplicate entries under the same date to avoid having the system error show. So an event can share the same name and title if it has a different parent essentially. But I can't seem to find a selector to test this. In words: if parent's name is $input->post->date and name is $input->post->name then set error to 1 Could anyone point me in the right direction? Thanks
  23. Hey guys its me again, I'm looking for a solution to show a List of Pages that have the same value in "fieldset-x" as the current Pages "title" e.g. . My hardcoded Solution looks like this: <?php $homepage = $pages->get("/stores/"); $stores = $homepage->children("location_category=1065, city=1010"); $children = $stores->getRandom(2); foreach($children as $child){ ... echo ... } ?> Now I need to check the title of the current page "{$page->title}" and check if it is equal to the value of fieldset "city" of a child Page of "Stores" ... Any ideas?
  24. Greetings all, I am trying to separate which pages display on the header menu and those which appear on footer menu. For that I created two checkbox fields, applied them to the templates, and now I am trying to filter them in the menu list. Here's my code: <?php [b]$homepage = $pages->get("/")->find("visibility_in_top_menu=1");[/b] $children = $homepage->children; // $children->prepend($homepage); $i = count($children)-1; foreach($children as $child) { $class = $child === $page->rootParent ? " class='on'" : ''; if($i>0){echo "<li><a$class href='{$child->url}'>{$child->title}</a></li>";} else {echo "<li><a$class href='{$child->url}' id='last'>{$child->title}</a></li>";} $i-=1; } ?> The thing is that I am probably not setting up the first line well. Can anybody help me out? Thanks!
  25. Hi guys and gals! I'm pretty new to ProcessWire, and trying to figure out as much as I can myself, but I'm totally stuck on this little piece though. • I've got a one-page scrollable site, and am using hashtags to jump to the next area (which is incidentally of course also a $page) • what I'm looking to do is link the next-page to an href, so I figured I could use $page->next, but that gives me a number (1007 in this case). Same goes for the siblings. What I thought would happen would be the following; just as $page->name gives me the current name (and thus the current hashtag) I figured 'next' would give me the name of the 'next' page. But I probably didn't do my homework. $page->next->name gives me 1007->name so that clearly isn't working. So to end this query: How do I get the name of the next page displayed so I can use it in my href? thanks for the help! p.s.: ->next is shown here: http://processwire.com/api/variables/page/ but not here: http://processwire.com/api/cheatsheet/
×
×
  • Create New...