Jump to content

Search the Community

Showing results for tags 'sort'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

  1. I've been using a function for some time now which sorts an array by the title of a linked page 'DMC_country_represented' title but then should reorder it by the parent page title to group the pages together. Recently the order is no longer working and a couple of the list items are out of alphabetical order. The only thing i'm aware of recently that has changed is a core upgrade to 2.7.2. Any advice welcome please. function dmc_list($names){ $dmcs = wire('pages')->find("template=dmc, DMC_represented=1, sort=DMC_country_represented"); $dmcs->sort("parent.title"); $total = $dmcs->count(); $items_per_column = ceil($total / 3); $count = 0; echo"<div class='row'>"; echo "<div class='col-md-4'>"; //start the first column echo '<ul>'; // start your first list foreach($dmcs as $dmc){ $region = $dmc->parent->title; $regionid = $dmc->parent->id; if($region !== $new_region) echo "<li class='list-group-item list-group-item-info'><b>{$region} {$regionid} </b></li>"; if($names=="names") { $showname = " - " . $dmc->title; } $link = "<a href='$dmc->url'>{$dmc->DMC_country_represented->title} {$dmc->sub_country->title} $showname {$regionid} {$count} of {$items_per_column} in total {$total}</a>"; echo "<li>{$link} </li>"; if(++$count%$items_per_column) { // this will be false when we are on the last item in column echo ""; } else { // this part will run when we are on the last item in the column echo "</ul></div>"; if($count !== $total) echo "<div class='col-md-4'><ul>"; // this will start a new column unless we're on the last item. } $new_region = $dmc->parent->title; // why the same variable? } // end foreach echo "</div>"; // end row }
  2. I am wandering to find out if it is easy something like: "..., sort=template, ..." or "..., sort=template.name, ..." for sorting the pages by their template name in selectors result. When it will be useful: 1. My clients were asking to display the professors first, then doctors, then students in the paginated staff list. 2. Other clients requested to display products pages first in the site search results. I know I could use two search selectors and to concatenate their PageArrays but it will be more complicated with the pagination. I could use a dropdown with "search in products", "search in site" too.
  3. 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?
  4. Hi I just need some advice on the best way to achieve this. The setup I have is: Items Item 1 Note 1 Note 2 Note 3 Item 2 Note 1 So I have note pages, which are children of item pages, which are within /items/. Each note has a 'created' datetime field on it. I also have a 'viewed_by' field which determines if a particular user has viewed that note. What I'm going to do is add the user's id to that field once they've viewed it. On the webpage that the user sees, I need to display items that have one or more notes that have not been viewed by the current user, most recent first (based on 'created' field). After that, I need to show all other items in date order, most recent first. Is there a way to sort the items like this using only ProcessWire $pages->get or $pages->find, or would I need to add the items to an array first and then loop through that? I thought I might have to loop through all the items to find ones that have an unread note, add those to an array, then loop through the remaining items and add those to the array. Thanks!
  5. Hi folks, I have a simple search setup, and I'm wanting the order of results to be sorted by parent then created date. I currently have this set up as: sort=-parent, sort=-created And here is a screenshot of my Tree structure from the CMS: However, when I get the search results; the result is putting Portfolio results before People results... any ideas where I am going wrong? I'm thinking it's to do with the fact that a 'person' has the parent 'People' but also 'People & Practice' but then couldn't work out why it was being returned in the order before 'Now'? EDIT: Thinking about it, it's because the ID of Portfolio is 1028 but the People ID is 1048; do I need to do it by sort first, then parent, then created? Thanks in advance, R
  6. I'm building a dashboard, based on the dashboard from Kongondo's Blog. In there i have Articles and Widgets. Articles are sorted by some date, but for the widgets i want to be able to use manual drag-n-drop sorting. Widgets are all child pages from a certain parent page. Is this possible and how would i be able to approach this? Would it be possible to build manual sorting into MarkupAdminDataTable or should i use PageTable instead? update: Im looking in to ProcessPageSort to see if i can use that. Seems it needs an AJAX call. update: Changed title of post
  7. i'd like to have a list of pages sorted by „creation“. $articles = $pages->find("template=x|y, sort=creation"); all the pages have a checkbox-field. the name of the checkbox-field is highlight. and it is a autojoin-field. i want all the highlight-pages listed above the others i don't know how to handle checked and not checked as a value this doesn't work $articles = $pages->find("template=x|y, sort=highlight, sort=creation" );
  8. Allow easy move & change order with $page API Semething like: $page->moveAfter($page); $page->moveBefore($page); $page->move($parent); // at end of collection
  9. 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!
  10. Hey folks, I'm attempting to order a list of subjects based on the number of pages (not child pages) that link to each subject. The end result will look like this: portrait — 120 items landscape — 78 items trees — 42 items beards — 8 items etc. I've been digging through the archive here, but I can't seem to find a solution. The issue is that I'm using wire('page')->find to get the list of subjects, and then getting the number of linked items inside the foreach — here's my code: $subjects = wire('page')->find("template=subject, sort=title"); foreach ($subjects as $subject) { $artwork = rendersubjectArtworkList(findartworks("subjects=$subject, limit=1")); $count = findartworks("subjects=$subject")->count; } I can't figure out how to either combine my queries or re-sort the list after the call. Any ideas? Thanks so much for any help!
  11. I need to save order for elements in global tree after using "page" fieldtype in other page. It's better to look on image attacheted to understand. I wish to know the better and easiest way to solve it or <code> example ! Thanks
  12. Hey people. as I have started building my second PW project, I have come to a little problem with items. So this is the planned sitemap: Frontpage -Products - -category 1 - -category 2 - -category 3 - -category 4 -Branches - -Branch 1 - -Branch 2 - -Branch 3 - -Branch 4 The idea is the categories have the items in their representable categories. These same items should be also visible on the Branch pages, but not in the same order. As I am mostly familiar with ExpressionEngine, I would put the items in the right categories, but as a attribute add which Branch they should be a part in. I've been getting some ideas from this: https://processwire.com/talk/topic/3579-tutorial-approaches-to-categorising-site-content/ But I find quite complicated and not sure what to really do. Also at a sidenote, The items should probably be the same kinda Child items as the Skyscraper Demo (Architects), but I can only manage to make new subpages...
  13. Hey I'm stuck with a issue how to filter repeater results depending on content. I have a few Option fields where you can select "yes", "no" or then leave it blank "". I got my loop working and I'm able to skip content that has not been set. Now I just need a filter for the loop. <? foreach($pages->get("/content/")->children as $c): ?> <div> <p> <?php if($c->titles) echo $c->titles; ?> </p> </div> <? endforeach;?> I was able to make a if-statement which checked if($c->Selector=="no"): but as it was in the loop, it kinda bugged out. Never got it working either outside the loop... One really hacky way I thought about was using CSS Classes to set classnames, and that way split what is shown and what is not. This is a really bad way as it still loads all the content for each Selector value. What I'm looking for is eg. a filter that every Selector with value "yes" will be looped, others dismissed. Any ideas how to work on with this?
  14. Hi, I'm having problems getting a series of images in the same standard images field to sort by date modifed/created. How would I add the ->modified property here to get the images to display in order of date modified/created? if ($page->images) { foreach($page->images as $image) { $thumbnail = $image->size(868,0); echo "<img class='r' src='{$thumbnail->url}'/>"; } } Have tried a few variation with no luck yet : ( thanks Alex
  15. Hey guys, So First Structure: Home [template=home] --Category [template=collection_list] ---SubCategory [template=collection_category] ----Articles [template=collection_basic] Each 'Articles' has a field called 'thumbnail' and 'banner'. I want to grab the latest article under a category and output the thumbnail and the banner. I'm quite new to PW (loving it so far) and I'm hoping you guys will be able to support me here.. I know it needs to look something like this... var_dump($pages->find("template=collection_basic, limit=1, sort=id")->thumbnail); ... Yes that's my var_dump but it's returning an error so. Would appreciate any help!
  16. Hi, I have encountered the following problem in the otherwise magnificent CMS ProcessWire: I'm sorting pages according to: "$page->children("sort=...". This is principally working fine, but the problem occurs when values like the following are returned: "10,4m3; 10m3; 8m3...". ProcessWire interprets them as text, which means that it thinks that e.g. "8m3" is greater than "10m3" seeing how the earlier begins on a greater number. Does anyone have any ideas how I could work around this issue, and indeed get PW to sort the values in the following order: "8m3; 10m3; 10,5m3...". Thanks!
  17. Currently when you upload images in PW, they are display in the order that they finished uploading - not necessarily in the order that they need to be in. I have a client that will be uploading approx. 100 images per page and needs them in filename order so that he can annotate each image using the description box. I can get PW to spit out the live page in the correct order: $images = $page->images->sort('name'); But this only works on the live page, which means that inside PW it is still a bit of a mess and my client still needs to reshuffle the images by hand in order to get the annotation right. Is there a way to get PW to sort the uploaded images in the page editor?
  18. Hi, I'm currently experimenting with using the excellent new PageTable field and have been unable to find an answer to this problem. When editing a page using the PageTable field, I am able to manually drag'n'drop the child pages created by the field. However when I save this doesn't seem to have any effect on the children that the PageTable field created in the admin PageList tree. I've tried setting the template with the PageTable field to sort children by 'manual drag n drop' and also tried setting it to sort children by the PageTable field but nothing seems to have an effect. TL;DR I can't get he manual sort order of pages created with PageTable field to be reflected in the sort order of the admin PageList tree. (The order in the admin PageList) (The order in the PageTable field) Thanks for any help with this!
  19. Hello everyone My question is very noobish, but I found no way to accomplish something simple. Also related posts in the forum where to difficult to work with for me … I would like to sort upcoming and past events which are repeaters by their end date field. The output should look something like this: UPCOMING EVENTS Title event 1 26. November to 27. November 2014 Title event 2 29. November 2014 … PAST EVENTS Title event 3 12. November 2014 Title event 4 1. August to 5. August 2014 … My code only returns the last of the created events as many times as there are events . Am I completely on the wrong way? Any hint would be very appreciated … Thanks, tron1000 setlocale(LC_TIME, 'de_DE'); echo "<h1>Events</h1>"; foreach($page->event as $event) { $event_title = $event->event_title; $date_to = $event->getUnformatted('event_date_to'); $today = time(); $date_from_formatted = strftime('%d. %B %Y', $event->getUnformatted('event_date_from')); $date_to_formatted = strftime('%d. %B %Y', $event->getUnformatted('event_date_to')); if ($date_from_formatted == $date_to_formatted) $event_out = "{$event_title}<br>{$date_from_formatted}<br><br>"; else $event_out = "{$event_title}<br>{$date_from_formatted} to {$date_to_formatted}<br><br>"; } echo "UPCOMING<br><br>"; if ($date_to > $today) foreach($page->event as $event) { echo $event_out; } echo "PAST<br><br>"; if ($date_to < $today) foreach($page->event as $event) { echo $event_out; }
  20. I'm trying to sort a PageArray by $page->name and because there are digits in the name I need to use a natural sort (like php's natsort()). I've gone through the process outlined in https://processwire.com/talk/topic/3392-emulate-natsort/ but I must be missing something because I can't get it to work at all. I then tried a different way and created an array of the page names, used natsort and implode to give me a correctly sorted string to use in a selector. I then do $output = $pages->find("name=$selector_text"); and the correct pages are returned but they're not in the same order as in my selector string. I've only found a couple mentions of natural sorting on the forums so I must be missing something simple but I just can't put my finger on it.
  21. Hi there, I'd like to sort some thumbnails that link to a detail page, this is the code: <?php $works = $pages->find("template=detail, sort=-date, limit=3"); echo "<ul id='itemContainer'>"; foreach($works as $w) { echo "<li> <div class='span3'> <a href='{$w->url}'><img src='{$w->slide_images->eq(0)->getThumb('thumbnail')}' > </a> <div class='pad15'></div> </div> </li>"; } echo "</ul>"; $pagination = $works->renderPager(); echo $pagination; ?> unfortunately, "sort=-date" doesn't seem to work...
  22. I've now twice noticed a problem after I deployed a version to a live server. For example the top buttons in Admin. Usually they are in the order: Pages Setup Modules Access Only when I pushed everyting (incl database export) live the order seems to have changed to Pages Modules Setup Access I also noticed a simple selector seems to ignore the sort I used, and used I think the ID for sorting. It was a critical moment so I quick-hacked a sort after the selector got it results, and thus was not able to get the source ot the problem. The production server uses CentOS with Php 5.2.17 and MySQL 5.0.51a Before I lose hours in debugging and testing, maybe anyone has noticed the same issues and already figured out what was wrong?
  23. Hi! I´m really liking ProcessWire, even though it´s a little intimidating to a complete PHP noob like me. The basics are pretty easy understand, but one function I still lack is the option to sort pages by custom fields. I looked at Ryans Scryscraper Site Profile to try to figure out how he did it for about 5 minutes before my brain exploded. I´ve also tried to search the forums without success. So if this is something that some of you PHP gurus could help me with that would be awesome. Here´s my question. Lets say I have a photos page with lots of photo pages in it which include custom fields such as resolution, camera, size etc.. How would i go about to list them by these fields? For example like this: select -option(Camera model from A-Z) -option(Camera model from Z-A) select -option(Highest resolution) -option(Lowest resolution) select -option(Highest size) -option(Lowest size) [Find] Thank you. /Jan Londén Edit: Here´s the final code. Remember this is an ugly copy/paste version from a non PHP programmer. Use at your own risk, etc.. If anyone wants to improve, make this more elegant, please do. Huge thanks to adrian who helped a lot. <?php /** * Books template * */ include("./head.inc"); $selector = ''; // For the keyword search input. Searches both title and body. if($input->get->keywords) { $value = $sanitizer->selectorValue($input->get->keywords); $selector .= "title|body%=$value, "; $summary["keywords"] = $sanitizer->entities($value); $input->whitelist('keywords', $value); } // For the book publisher select tag. Sorts alphabetically from A to Z. if($input->get->book_publisher == 'desc') { $value = $sanitizer->selectorValue($input->get->book_publisher); $selector .= "sort=book_publisher,"; $summary["book_publisher"] = $sanitizer->entities($value); $input->whitelist('book_publisher', $value); } // From Z to A. elseif($input->get->book_genre == 'asc') { $value = $sanitizer->selectorValue($input->get->book_genre); $selector .= "sort=-book_genre,"; $summary["book_genre"] = $sanitizer->entities($value); $input->whitelist('book_genre', $value); } // For the book chapters select tag. Sorts numerically from highest to lowest number of pages. if($input->get->book_chapters == 'desc') { $value = $sanitizer->selectorValue($input->get->book_chapters); $selector .= "sort=book_chapters,"; $summary["book_chapters"] = $sanitizer->entities($value); $input->whitelist('book_chapters', $value); } // From lowest to highest. elseif($input->get->book_chapters == 'asc') { $value = $sanitizer->selectorValue($input->get->book_chapters); $selector .= "sort=-book_chapters,"; $summary["book_chapters"] = $sanitizer->entities($value); $input->whitelist('book_chapters', $value); } // For the book pages select tag. Sorts numerically from highest to lowest number of pages. if($input->get->book_pages == 'desc') { $value = $sanitizer->selectorValue($input->get->book_pages); $selector .= "sort=book_pages,"; $summary["book_pages"] = $sanitizer->entities($value); $input->whitelist('book_pages', $value); } // From lowest to highest. elseif($input->get->book_pages == 'asc') { $value = $sanitizer->selectorValue($input->get->book_pages); $selector .= "sort=-book_pages,"; $summary["book_pages"] = $sanitizer->entities($value); $input->whitelist('book_pages', $value); } ?> <form id="book_search" method="get" action="<?php echo $config->urls->root?>books/"> <h3>Browse books</h3> <p> <label for="search_keywords">Search</label> <input type="text" name="keywords" id="search_keywords" value="<?php if($input->whitelist->keywords) echo $sanitizer->entities($input->whitelist->keywords); ?>" /> </p> <p> <label for="book_publisher">Publisher</label> <select name="book_publisher" id="book_publisher"> <option value="">Any</option> <option value="desc"<?php if ($input->get->book_publisher == 'desc') { echo ' selected="selected"'; } ?>>Alphabetically A-Z</option> <option value="asc"<?php if ($input->get->book_publisher == 'asc') { echo ' selected="selected"'; } ?>>Alphabetically Z-A</option> </select> </p> <p> <label for="book_chapters">Number of chapters</label> <select name="book_chapters" id="book_chapters"> <option value="">Any</option> <option value="desc"<?php if ($input->get->book_chapters == 'desc') { echo ' selected="selected"'; } ?>>Highest to lowest</option> <option value="asc"<?php if ($input->get->book_chapters == 'asc') { echo ' selected="selected"'; } ?>>Lowest to highest</option> </select> </p> <p> <label for="book_pages">Number of pages</label> <select name="book_pages" id="book_pages"> <option value="">Any</option> <option value="desc"<?php if ($input->get->book_pages == 'desc') { echo ' selected="selected"'; } ?>>Highest to low</option> <option value="asc"<?php if ($input->get->book_pages == 'asc') { echo ' selected="selected"'; } ?>>Lowest to high</option> </select> </p> <p> <input type="submit" id="book_submit" name="submit" value="Find" /> </p> </form> <?php $books = $page->children($selector); ?> <?php if (count($books)) : ?> <ul> <?php foreach($books as $book) : ?> <li> <p> <a href="<?=$book->url?>"><?=$book->title?></a><br> Publisher: <?=$book->book_publisher?><br> Number of chapters: <?=$book->book_chapters?><br> Number of pages: <?=$book->book_pages?> </p> </li> <?php endforeach ?> </ul> <?php else : ?> <p>No books were found.</p> <?php endif ?> <?php include("./foot.inc"); You might need to change desc/asc values to get them working the way you want.
  24. Hi guys, I'm running into a few issues trying to use my sorting dropdown on a table to play nicely with digits in a string. My table currently has a total as one of its columns and I have created a select dropdown to choose the sorting method: <form action="./" method="post"> <select name="sort" onchange="form.submit()"> <option value="title">Sort by...</option> <option value="title">Invoice number A-Z</option> <option value="-title">Invoice number Z-A</option> <option value="invoice_total">Invoice Total A-Z</option> <option value="-invoice_total">Invoice Total Z-A</option> <option value="invoice_status">Invoice Status A-Z</option> <option value="-invoice_status">Invoice Status Z-A</option> <option value="invoice_client">Client Name A-Z</option> <option value="-invoice_client">Client Name Z-A</option> <option value="invoice_date">Invoice Date A-Z</option> <option value="-invoice_date">Invoice Date Z-A</option> </select> </form> <?php foreach ($page->children("sort={$input->post->sort}") as $invoice) { ?> I've just realised that it will struggle to sort my invoice_total as I believe it may need natsort() applying to it. The problem is when I try this, it seems to completely empty the pageArray. Could anyone give me a pointer? Thanks
  25. First time using ProcessWire. As a developer I've been impressed so far. Having trouble sorting a series of pages that are children of a top level page. I've tried sorting them from the Pages page (/admin/page/) as well as from the Children tab of the parent page. I watch the network traffic in Chrome and see that when I move one of the pages there is a POST to /admin/page/sort/ with form data that includes sort= . But when I reload either admin page, or reload the site page that lists them, the order is unchanged. What am I missing here? Thanks!
×
×
  • Create New...