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. 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!
  3. 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 != ?
  4. 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
  5. 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) ...
  6. 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
  7. 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
  8. 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
  9. Hello all, this is a real beginner's question, I guess. Got stuck on how to select the nth child of a page. Couldn't find the right selector at the API cheatsheet or am just to stupid to understand them right. Also searched the forum. What I want to achieve is something like $page->child(2nd); I tried $page->child("start=2"); but the script then just stops there without throwing an error. I'm sure that should be pretty simple but have no clue atm. Thanks in advance gerhard
  10. I am using the below to go several levels deep, but when using a select of "limit" or "sort" I am getting strange results. For example, if limit=2 I get five results. If limit=3 I get six results. I am sure I have messed up something. Maybe there is a better way? $cats = $pages->get("/mypage/")->children; // get children of the parent foreach ($cats as $cat) { $menu .= "<div>"; $menu .= "<h2 class='titlebg'>$cat->title</h2>"; if($cat->children) { // if they have children $menu .= "<ul>"; foreach($cat->children as $subchild) { foreach ($subchild->children("limit=2, sort=-date, sort=title") as $child) { $menu .= "<li><a href='{$child->url}'>$child->title</a></li>"; } } $menu .= "</ul>"; } $menu .= "<span><a href='{$cat->url}'>See More</a></span>"; $menu .= "</div>";
  11. 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!
  12. 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
  13. 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
  14. 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!
  15. 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!
  16. 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
  17. 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!
  18. 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!
  19. 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
  20. 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
  21. Hi guys, Any ideas on how to get all pages of a certain template that have been created this month? I have tried to test for "created" within the selector and combining it with date("m") but I'm not sure how to go about this? My goal is to set invoice numbers combing an autoincrementing value with each invoice that is created within a given month. Any ideas? Thanks
  22. 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?
  23. 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/
  24. Hey, I need to select some pages that have a datetime between 2 user input datetimes. Now I use the datetime from pw and in the selector i try to select it with $r = $pages->find("template=transaction, datetime>=$start_date, datetime<=$end_date); Now my $start_date and $end_date are formatted by 31-12-2012 but also tried 2012-12-31 And when i try to select a page with a datetime of 03-12-2012 with <=04-12-2012 i get nothing and if 07-12-2012 i get all the pages... What am I doing wrong? Thanks in advance, sorry for the weird explaination, its friday. So i figured out what the problem was, it was something in the code later on... I am stupid D:
  25. Hi, was just wondering what the best way to access a page field in a selector would be? Is ID the only way? So: $geo_students = $pages->find('template=student, subject=1102, sort=title'); Or would there be another way? Thanks.
×
×
  • Create New...