Jump to content

Search the Community

Showing results for tags 'find'.

  • 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. Media Lister Lists images and files from across the site in a sortable and filterable table. For images you can choose between table, small thumbnails and large thumbnails view modes. The module retrieves the data using SQL queries so is able to efficiently list media information for all but the largest of sites. Possible use cases: Check that a nice variety of banner images is used for top-level pages. Find duplicate files/images by sorting by filesize or filename. Find images without descriptions if this is important for use in alt tags. Find large PDF files that would benefit from optimisation. Check for "inappropriate" images, or images that are not "on-brand". Images in small thumbnails view mode Files saved as a bookmark Controls Media type: Choose between Images and Files. View mode: When listing images you can choose between small thumbnails, large thumbnails and table view modes. When in one of the thumbnail view modes you can see information about the image in a tooltip by clicking the "i" icon, or edit the page containing the image by clicking the pencil icon. From pages matching: This field allows you to add filters to limit the pages that the media will be listed for. Add bookmark: Superusers can add bookmarks for the current settings that will be available from the flyout menu for all users. See the bookmarks section below for more information. Column visibility: Choose the columns that appear in the table and in the information tooltip (when in thumbnails mode). Search: Quickly filters the results to show only items that have the search text in any column, whether the column is visible or not. Custom search builder: For more advanced searches where you can combine conditions for specific columns with AND/OR logic. Pagination: You can navigate through the results and set the number of results per page. Reset: Click the "Reset" button at the top right to return to the default settings for Media Lister (or for the current bookmark if applicable). Editing the page that contains the media For any media result click the link in the "Page" column to open the page that contains the media item in Page Edit. When in thumbnail view mode you can click the pencil icon to achieve the same thing. The field that contains the media item will be focused. When a media item is contained within a Repeater field this is indicated by an asterisk at the start of the page title. When opening Page Edit for a media item within a Repeater field the Repeater item will be automatically expanded, including for nested Repeaters. Limitations for values that are merged in the database The module has limited support for multi-language values and custom fields for images/files. In order to be efficient enough to handle large sets of results the module retrieves raw values from the database, and in the case of multi-language values and custom field values ProcessWire stores these in JSON format in a single database column. The module improves the display of this JSON data by extracting the uploadName value into a separate column, substituting custom field labels for field IDs, adding language names where possible, and by transforming the data into a quasi-YAML format for better readability. Some limitation remain though – for example, if you use Page Reference fields in the custom fields then only the page IDs are displayed. Bookmarks Superusers are able to create a bookmark for the current Media Lister settings by expanding the "Add bookmark" field, entering a title for the bookmark, and clicking the "Add bookmark" button. Bookmarks will be visible to all users from the flyout menu. You can delete a bookmark from the module config screen. Module config In the module config screen you can define defaults for controls such as media type, view mode, pagination limit and column visibility. You can also delete bookmarks from the module config screen. https://github.com/Toutouwai/ProcessMediaLister https://processwire.com/modules/process-media-lister/
  2. Find Merge Adds a Pages::findMerge() method that allows multiple PageFinder selectors to be merged into an efficient paginated set of results. This can be useful when you need more sophisticated sorting of results than what would be possible using only the sort value in a single $pages->find(). Details $results = $pages->findMerge($selectors, $options); $selectors is required and must be an array of selectors. Each selector can be in string format or array format. The findMerge() method will loop over the selectors in the order supplied, adding matching pages to the final results. $options is an optional associative array of options. limit (int) Limit for pagination. start (int) Manually override the start value rather than have it be automatically calculated from the current page number. excludeExisting (bool) Whether or not to exclude pages in each selector that have already been matched by a previous selector. Default is true. keepFirst (bool) When excludeExisting is false then a page might match more than one selector in the supplied array. But each page can only appear once in the results and if keepFirst is true then the page will appear in its earliest position in the results, whereas if keepFirst is false it will appear in its latest position in the results. Default is true. As a shortcut you can supply an integer as the second argument and it will be treated as the limit for pagination. Basic usage For most use cases only a limit will be needed for the $options argument. $selectors = [ 'title%=yellow', // title contains "yellow" 'title^=z', // title starts with "z" 'title=elephant', // title equals "elephant" 'template=colour, sort=-title, limit=3', // 3 colours in reverse alphabetical order 'template=country, sort=title, limit=40', // 40 countries in alphabetical order ]; $results = $pages->findMerge($selectors, 10); if($results->count) { echo "<p>Showing results {$results->getPaginationString()}</p>"; echo "<ul>"; foreach($results as $result) { echo "<li><a href='$result->url'>$result->title</a></li>"; } echo "</ul>"; echo $results->renderPager(); } Advanced usage The following notes are only relevant to rare cases and most users can safely skip this section. In the demo example the colour page Yellow will potentially match both the 1st selector and the 4th selector. Because of this the excludeExisting and keepFirst options will have an effect on the results. excludeExisting option false Note that the 4th selector asks for 3 colour pages (limit=3). By default excludeExisting is true, which means that when the 4th selector is processed it is interpreted as saying "find 3 colour pages in reverse alphabetical order that have not already been matched in an earlier selector". We can see that there are 3 pages in the results from that selector: Violet, Red, Orange. But if excludeExisting is set to false then the results are different. The matches of the 1st selector (Yellow, Yellow Warbler) are not excluded from consideration by the 4th selector (the 4th selector matches will be Yellow, Violet, Red), and because each page can only appear once in the results this means that the 4th selector ends up only adding 2 more pages to the results. $selectors = [ 'title%=yellow', // title contains "yellow" 'title^=z', // title starts with "z" 'title=elephant', // title equals "elephant" 'template=colour, sort=-title, limit=3', // 3 colours in reverse alphabetical order 'template=country, sort=title, limit=40', // 40 countries in alphabetical order ]; $options = [ 'limit' => 10, 'excludeExisting' => false, ]; $results = $pages->findMerge($selectors, $options); keepFirst option false As described above, the Yellow page potentially matches both the 1st and 4th selector. By default Yellow will appear in its earliest position within the results, i.e. the position resulting from it being matched by the 1st selector. But if keepFirst is set to false (and excludeExisting is false) then it will appear in its latest position within the results, i.e. the position resulting from it being matched by the 4th selector. $selectors = [ 'title%=yellow', // title contains "yellow" 'title^=z', // title starts with "z" 'title=elephant', // title equals "elephant" 'template=colour, sort=-title, limit=3', // 3 colours in reverse alphabetical order 'template=country, sort=title, limit=40', // 40 countries in alphabetical order ]; $options = [ 'limit' => 10, 'excludeExisting' => false, 'keepFirst' => false, ]; $results = $pages->findMerge($selectors, $options); keepFirst has no effect when excludeExisting is true. https://github.com/Toutouwai/FindMerge https://processwire.com/modules/find-merge/
  3. ProcessWire added the numReferences property in 3.0.107, which returns the count of all pages having a reference to the page object. However, apparently it's not possible to use this property inside a selector. I'm trying to find all pages that are referenced at least once: $pages->find('template=service, numReferences>0'); This throws an error: "Field does not exist: numReferences". Is there another way to filter by the number of references? Of course, I could manually filter the results of the find query, but that feels overly complicated. Ideally, I would also like to filter the number of references from a specific field; that is, find all pages that are referenced at least once in one specific page reference field. Is there a way to do this? I guess supporting numReferences in selectors would be a feature request - if so, is it feasible? Thanks!
  4. I played with the Selectors object and would like to use it for a special use case... That is a custom Selectors object with dummy data converted to an php array to see the structure (Selectors object is a WireArray with "fields" added) Array ( [0] => Array ( [0] => Array ( [field] => seg1 [value] => val1 [not] => [group] => [quote] => [forceMatch] => ) [1] => Array ( [field] => seg2 [value] => val2 [not] => [group] => [quote] => [forceMatch] => ) ) ) But instead of "seg1" the field name is "field" with value "seg1" (= my field name). So I can't search the Selectors WireArray (= custom WireArray with added Selectors objects) with PW "find('seg1=val1')", Is there a way to search with "find()" or build a simple wrapper to make the elements searchable / filterable with find()?
  5. Hello, I'm struggling with this : a 'group' field of 'Page' type. The parent of selectable pages is '/groups', the template is 'group', and a member can create some groups in the /groups tree. I would like this user to see only the groups he or she has created so in my 'Find selector' in the backend, I would like to use : template=group, created_users_id=$user->id But that doesn't seem to work... I still get the list of all available groups in the /groups tree. Any idea ? I had a feeling I had already seen that before (something like $user->id must be replaced by users_id or something, but I can't find anything in the Forums... and all my tests keep failing...
  6. Apologies if this has been covered. I tried a search but didn't hit the usecase I'm after. I currently have category pages listing their children products. Someone asked me to put a product in multiple categories, so I created a Page Reference field called prod_othercategories which lets a user pick multiple product category pages. When I try to output a list of products for a category page, I came around to the following selector: $pages->find("prod_othercategories|parent=$page, template=prod_series, sort=title, prod_status_pages!=1554|1559|1560|4242"); Only the first selector item is giving me trouble, but I'm including the entire string in case something is conflicting and I'm not realizing it. The output is currently only outputting matches for "parent" and ignoring prod_othercategories. I tried listing parent first in the selector but it had no effect. Appreciate if someone could help me with this! Thanks!
  7. Hello ! I have somehting I don't understand here... Here's my code : $allPlayers = $pages->find("parent.name=players, team=$selectedTeam"); $allTrains = $allPlayers->find("template=event, task.name~=ut-action, refPage!='', date>=$startDate, date<=$endDate, sort=refPage, sort=date"); bd('$allTrains:'.$allTrains->count()); // DISPLAYS 0 ???? foreach($allPlayers as $p) { $allTrainings = $p->find("template=event, task.name~=ut-action, refPage!='', date>=$startDate, date<=$endDate, sort=refPage, sort=date"); $test += $allTrainings->count(); } bd('$test:'.$test); // DISPLAYS 883 pages (normal) As you can read from my comments, I have no idea why my first $allTrains stays at 0 while the second request actually finds the corresponding pages. If someone could explain I'd appreciate a lot. I have been struggling with this for hours now... For your information, my pages having template 'event' are in a subtree like so : - player 01 - history-1 - event 01 - event 02 - event ... - history-2 - event 01 - event ... - player 02 - history-1 - event 01 - event 02 - event ... - history-2 - event 01 - event ... - player ... - history-1 - event 01 - event 02 - event ... - history-2 - event 01 - event ... Thanks in advance. (sorry for my preceding 'tree' which doesn't look like much. I need to find a way to output this better ? )
  8. I am trying to filter my $pages with a find($selector method). $matches = $pages->find($selector); and this is an example of what my selector looks like $selector = "include=all, title|body~=$q, limit=50"; In this case, it only searches according to the matching exact words. For example:we search="art", the result="art times","these art",.... Is there any way to search based on the alphabet? For example: we search="ab", the result="absolutely correct","abstract art",....
  9. Hello, How would I get the DB query that is used to gather the data for something like wire('pages')->find("template=log, id_gc={$serverId}, timestamp>={$dateStart}, timestamp<={$dateEnd}, sort=timestamp"); Tried using the Debug Mode Tools in the backend on a lister with similar selector. But I couldn't make out the right query in there. I'd like to use that query directly to dump data from the DB to a csv via SELECT INTO. Processing 10.000s of pages in chunks of 100 via the API into a csv. This is quite time consuming (several minutes for ~20.000 pages that result in a ~13MB csv file). Any help would be much appreciated.
  10. Hello, I passed through a lot of documentation about selectors and a few post in the forum but and I did not find my answer so I'll try here :). Question: Is there a way to find pages that have a certain field attached to his template ? Use case: // Site structure Products Computers Computer #1 (has field cached_details) Computer #2 (has field cached_details) Electronics Test #1 Pet Supplies Test #2 (has field cached_details but is empty) // If I want to get all children of page "products" that contains the field "cached_details" I would do something like this // $products => PageArray $results = $products->children("has_field=cached_details"); // or this $results = $products->children("cached_details!=null"); // Expected: $results would contains [Computer #1, Computer #2, Test #2] // Instead I have to do this $results = new PageArray(); foreach($products->children as $child) { if ($child->hasField("cached_details") === true) { $results->add($child); } } Thank you in advance guys :),
  11. I'm wondering about creating a query that involves looking across two different parent page trees. One parent is for blog posts and it has each post under that. Another parent is used for categories and subcategories for the blog. Then in the blogs there is a page field that can reference the categories. This is all pretty normal setup so far. I created a navigation that lists the current category and its children, but I want to not show categories that have no posts. For some reason I'm drawing a blank. So let's say a user clicks category1, and it shows a blog listing for that category. I query for all the child categories of the current one. Now I want to exclude any categories where NO blogs exist that make reference to the category (an unused category). How do I do this in a way that is performant? I don't want to have to query the blogs tree over and over to test for the presence of each category in the list! Here is the tree: blogs - article1 [pagefieldcat = "cat1"] - article2 [pagefieldcat = ""] categories - cat1 - cat2 Now when I get all children of categories, I want to exclude cat2 since it's not referenced from any blogs. Can I do this without having to loop and query every category against every blog one by one? Thanks
  12. Hello, Still in my 'teaching game'. Here's my problem : I 'find' all players with a request like $allPlayers = $pages->find("template=player"); [/code Then, I limit to players belonging to the team of the logged in player with [code] $teamPlayers = $allPlayers->find("team=$loggedPlayer->team"); No problem so far. But my scoreboards rely on either : $allPlayers->getItemKey($loggedPlayer); or $teamPlayers->getItemKey($loggedPlayer); to find the logged player's position in the charts. On the 'global' newboard with scoreboards based upon $allPlayers, everything works as expected. BUT on my 'team' newsboard, even though I'm using $teamPlayers, the returned indexes are based upon $allPlayers. Am I clear ? In other words, I have a total of 125 players, and my logged player is 61 out of 125 regarding the number of places he freed. But in his particular team of 25 players, he sould be 15 whereas he's still 61 I'd like to reset my indexes (and start back from 0), but I can't find my way out of this... If someone has a hint to help, I'd appreciate. I have a second part in my worry : I had a way around it by simply making another 'raw' request : $teamPlayers = $pages->find("team=$loggedPlayer->team"); Then my team indexes were right, but I faced another issue : Reordering my wirearray according to the scoreboard I want usually worked fine (simple sort() based upon an integer field, for example, player's coins, player's karma...) and indexes were updated BUT resorting with places.count ('places' field is a pageArray) doesn't update the indexes returned by getItemKey and my logged player is always at the position he was when I first did my initial $pages->find() query So my way around found its limit and that's why I'm posting here, after struggling with this for a couple of hours... Thanks in advance for the help.
  13. Hello to all, This time, I'm stuck on an issue with a 'find' request. I have found a turnaround, but I have no idea what's going on, really, and I wish I could understand. My code is the following : $nbEl = $player->places->count(); $items = $pages->find("template=place|item|equipment, GC<=$player->GC, level<=$player->level, freeActs<=$nbEl")->sort("template, name"); If I explain briefly : the $items should contain the possible elements for a player according to his level and GC (gold coins), and freeActs, i.e. the number of already 'bought' places. If the 1st line $nbEl returns a number higher than 0, it 'works', I get some items. BUT if the player has not bought any place yet and then $nbEl = 0, $items is... empty whereas it should contain all elements being accessible with a 0 'freeAct' field (and there are many). I have tried to hard-code 'freeActs<=0', I get no items. 'freeActs<=1', I get some nice results' AND THEN, 'freeActs=0' and it works as expected So here's my 'workaround' : $nbEl = $player->places->count()+1; $items = $pages->find("template=place|item|equipment, GC<=$player->GC, level<=$player->level, freeActs<$nbEl")->sort("template, name"); Note the 'freeActs<$nbEl' instead of 'freeActs<=$nbEl' and the '+1' for $nbEl so not to start at 0... Then, it works as expected !?!? Does someone have an explanation for this ? Thanks in advance if you do. And don't hesitate asking me for more details/explanations if you need.
  14. Hey! Quick question, Should I limit how many find() methods I use on a single page? Is it fairly resource-intensive? I am getting consistent 2006 MySQL server has gone away errors and have followed all the suggestions I can find, but wonder if I am just "overloading" my server resources with database requests or something like that? Thank you!
  15. Hi, I'm sure this is maybe in the works already, given that findMany() is a recent addition to the API, but having this (and the other new find options) available to $users would be a great addition. Cheers, Chris NB Communication
  16. Hi! I've got a page with text area where user can check some codes divided by space, semicolon or comma. I can use two solutions to search for these codes: First method: $prCodesArray = preg_split('/[\\s,;]+/', $prCodes, -1); $selector = "title=" . implode("|", $prCodesArray) . ", template=pr-code, include=all, limit=100"; $prCodePages = $pages->find($selector); $prCodeCount = count($prCodePages); if ($prCodeCount) { foreach ($prCodePages as $prCodePage) { $content .= $prCodePage->title . " - " . "<span title=\"". $prCodePage->parent->pr_code_group_description . "\">" . $prCodePage->parent->title . "</span> - " . $prCodePage->pr_code_description . "<br>"; } } else { $content .= $prCode . __(' - Not found.') . "<br>"; } Advantages: + it's fast ~0.21s for ~40 codes. Disadvantages: - alphabetical results sorting while I want input order, - doesn't show not found codes. Second method: $prCodesArray = preg_split('/[\\s,;]+/', $prCodes, -1); foreach ($prCodesArray as $prCode){ $selector = "title={$prCode}, template=pr-code, include=all, limit=10"; $prCodePages = $pages->find($selector); $prCodeCount = count($prCodePages); if ($prCodeCount) { foreach ($prCodePages as $prCodePage) { $content .= $prCodePage->title . " - " . "<span title=\"". $prCodePage->parent->pr_code_group_description . "\">" . $prCodePage->parent->title . "</span> - " . $prCodePage->pr_code_description . "<br>"; } else { $content .= $prCode . __(' - Not found.') . "<br>"; } } } Advantages: + sorting like input order, + shows not found codes. Disadvantages: - it's slow as hell ~2.5s for ~40 codes. Is there any solution to join advantages of both methods? Also, as you can see I have to use include=all statement in my find methods and I don't know why. I've used Import Pages from CSV module. All codes (pages) are published and there is no access control on any of them.
  17. I just had a duh! moment and thought I should share as it may be useful to others, especially PW beginners. I know a lot of you will go "yeah well duh...." and yeah, well I feel like a bit of an idiot but anyways.... I had a page outputting a table detailing data from about 200 records (PW pages). For each record it searched for child pages of a certain template, probably averaging 3 child pages per record and added some data from those pages to each row of the table. Simple stuff. The page was averaging about 12 seconds to load. Anyway, today I got frustrated enough to try to work out why it was so slow. Turns out I realised that the child pages I was searching for were all direct children, so I changed my search method from $pages->get(....)->find(.....) to $pages->get(.....)->children(.....) and blow me down the page load has gone from 12 seconds to a tad over 1 second. Turns out each child page had many child pages of their own (thousand of pages in total) and all these were being searched with the find() method. Stupid mistake, but I think right from the beginning of my learning of PW the find() method was ingrained. So hopefully this helps some newbies and others like me. Check out http://cheatsheet.processwire.com/page/built-in-methods-reference/page-find-selector/ and http://cheatsheet.processwire.com/page/built-in-methods-reference/page-children-selector/ for more info on these methods and others.
  18. Working with a multi-language site. I have a field 'province' with the list of provinces in Options in English and in French tab. The field is selectable in the 'municipality_page' template as a dropdown box. I have an Ajax call to retrieve the choice of the province to list the municipalities of that province. Everything works well in English, however, I am having an issue with the French, I don't know if it is because the French provinces uses accents and dashes in them. I was able to make it work for 9 out of 12 provinces with the following code. $province = $_GET['prov']; if(strpos($province, "-") !== false){ $choice = str_replace("-", "|", $province); } else { $choice = $province; } $entries = $wire->pages->find("template=municipality_page, province%=$choice"); Just can't figure out how to get 'Colombie-Britannique', 'Nouvelle-Écosse' and 'Territoires du Nord-Ouest' to be found. I tried manually with the code below, but it didn't even worked. It also doesn't seemed to be a typo in the field. $entries = $wire->pages->find("template=municipality_page, province%=Colombie-Britannique"); What is missing in the code to be able to find those 3 provinces?
  19. I extended my users-template with a lot af fields? One of them is 'instrument' The code beyond is working fine (see screenshot 1). 'instrument' is a page-select-field in the user template (the pages are violin, cello, clarinet, ...). But this is not nice and efficient coding!! // Violin $person = $users->find('instrument=violin'); echo "violin"; foreach ($person as $p) { // $user fields are shown echo $p->first_name; } // cello $person = $users->find('instrument=cello'); echo "cello"; foreach ($person as $p) { // $user fields are shown echo $p->first_name; } // clarinet $person = $users->find('instrument=clarinet'); echo "clarinet"; foreach ($person as $p) { // $user fields are shown echo $p->first_name; } // and so on With a foreach the code could me more efficient, but the find-selector givns a problem with the variable $instr. // all instrument in a foreach foreach ($user->instrument as $instr){ $person = $users->find('instrument=$instr'); // does not work, neither do find('$instr') and find($instr) echo $instr->title; foreach ($person as $p) { // $user fields are shown echo $p->first_name; } } With $person = $users-find($instr); only the value of $instr is shown (e.g. violin) but not the values of $p (e.g. first name of person. (see screenshot 2) How can I use a variable as find-selector?
  20. I have a small issue with my $pages->find query. My pages have a repeater field that is a checkbox. I'm trying to sort the results so that I get pages where at least one of the repeaters has the checkbox field checked. What I'm doing currently is: $my_pages = $pages->find("sort=-my_repeater.my_checkbox_field"); So I'm sorting high to low, i.e. checked before not checked. The issue is that it only appears to take into account the checked status of the first repeater item. If the second, third etc is checked, the page is not appearing at the top of the results. I'm guessing there must be an easy way to check all items in the repeater?
  21. Hi, I build a new module and try to convert data into WireArray to get the PW API benefits (find('selector'), get('selector'), ...). Some code to my tests... Define a custom WireArray class class CustomWireArray extends WireArray { public $toStringString = ''; public function __toString() { return $this->toStringString; } public function __get($key) { return $this->$key; } public function __set($key, $value) { $this->$key = $value; } } Create a new CustomWireArray $customWireArray = new customWireArray(); Create a new array item $item = new customWireArray(); // set properties to $item... $customWireArray->add($item); // add to the customWireArray So far it works fine. No problem to find() / get() properties from the $customWireArray, but I need sub-items Tested it with a sub-customWireArray and also a simple stdClass, but it won't work with PW find() / get(). Is there a way to get sub-properties work with something like that? $result = $customWireArray->find('property.subfield=MyValue');
  22. Hello, I would like to find all fields that are multi-language. My code $langFields = new FieldsArray; foreach ($fields as $f) { if($f->type instanceof FieldtypePageTitleLanguage || $f->type instanceof FieldtypeTextareaLanguage || $f->type instanceof FieldtypeTextLanguage) { $langFields->add($f); } } Is there a more generic way of how I can determine whether a field is multi language, other than checking "$f->type instanceof" for all three fieldtypes?
  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. EDIT: Not sure why it didn't work the first time I tried it, but creating a tag without the space or hyphen did eventually work. I'll have to use my workaround (since I can't omit the space in the title of the page). Mods are welcome to delete this post or leave it for someone else who might run into the same thing. I thought I was doing something to make life easier on myself (this is how all tragedies begin). On a site (live, of course), I had two separate areas where product literature documents were referenced. There is a product literature section, and individual product pages. Before, in each template, I was linking to static URLs for files that were placed on the site via FTP. What usually happened was that I'd upload a file to the Literature section and forget to add it to the product page. Yesterday I decided that it would be less complicated (and more fool-proof) to use a File upload field in the Product Literature section, with tags that match the titles of the product pages, so that the product's template could pull from the same files. I thought tags would allow me the flexibility to add any tag I might need down the line. With some fits and starts, I got it working yesterday for two categories of document (I thought). Today, I tried to finish up the task and noticed that two of the products are not pulling any documents at all. My first instinct, because mysql searches have burned me before, was that the tags "Spectra 500" and "RDS-30" were falling under the search term limits. "Spectra 1000" and "Spectra 1100" work as intended. Reading up in the forums seemed to agree about the search phrase length. I went to the site and did a quick change up of the product page's title and the tags on the document to test, but changing the terms to "Spectra500" and "RDS30" didn't correct it. Later this did start behaving as expected, not sure why I had misleading results from my first attempt. So I set up and coded a workaround (thinking a multi-Page Select field on the literature page and a corresponding text field for the product pages). Final code to pull files on pages of template "document" using Page Multiselect from the template of pages of template "product": $datasheets = $pages->find("parent=/product-literature/product-data-sheets/,template=document,product_tag=$page"); $manuals = $pages->find("parent=/product-literature/product-instruction-manuals/,template=document,product_tag=$page"); if(count($datasheets)) { echo "<div class='col span_2_of_4'>"; echo "<section class='reports'>"; echo "<h4 class='section_names'>Available Product Documentation</h4>"; foreach($datasheets as $datasheet) { echo "<div>"; $datasheetLink = $datasheet->get("254_file")->url; echo "<a href='{$datasheetLink}' target='doc_window'><img src='{$config->urls->assets}images/documenticon.png' class='floatleft' alt='{$datasheet->title}'>"; echo "<p class='file_names'>{$datasheet->headline}</p></a>"; echo "</div>"; } if(count($manuals)) { foreach($manuals as $manual) { echo "<div>"; $manualLink = $manual->get("254_file")->url; echo "<a href='{$manualLink}' target='doc_window'><img src='{$config->urls->assets}images/documenticon.png' class='floatleft' alt='{$manual->headline}'>"; echo "<p class='file_names'>{$manual->headline}</p></a>"; echo "</div>"; } } echo "<br /> <br /></section>"; echo "</div>"; } else if(count($manuals)) { echo "<div class='col span_2_of_4'>"; echo "<section class='reports'>"; echo "<h4 class='section_names'>Available Product Documentation</h4>"; foreach($manuals as $manual) { echo "<div>"; $manualLink = $manual->get("254_file")->url; echo "<a href='{$manualLink} target='doc_window'><img src='{$config->urls->assets}images/documenticon.png' class='floatleft' alt='{$manual->headline}'>"; echo "<p class='file_names'>{$manual->headline}</p></a>"; echo "</div>"; } echo "<br /> <br /></section>"; echo "</div>"; }
  25. Greetings I'm new to PW, and think it's fantastic! Never, ever, have I seen such an amazing CMF! Anyways, to my question: I had set some Hanna Code to render a list of page suggestions on the http404 page, which works perfectly. The problem, however, comes in when I use repeaters, which are page instances. The page suggestion renderer has the following: $suggestions = $pages->find('name|title|summary|body%='.$request); I have a page that is named services-industries, and repeaters with the word services in the name. As such, repeaters appear in the suggestion results-list if applicable to the search. How can I exclude/remove those?
×
×
  • Create New...