Jump to content

Search the Community

Showing results for tags 'sort'.



More search options

  • 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
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Categories

There are no results to display.


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

Found 50 results

  1. Hello, i need to sort $pages by the first letter an show on the page like A - Aname Page - Aname Page - Aname Page - Aname Page B - Bname Page - Bname Page - Bname Page - Bname Page How can i check which is the first letter from the page.title ?? Tnx
  2. What's the easiest way to retrieve a PageArray -- with an offset and a limit, for use in paginated search results -- that is sorted by title using PHP's SORT_NATURAL instead of alphabetically? I was hoping there was a config setting or API method that would handle it for me, but if there is, I haven't stumbled across it yet.
  3. I have done a bit of searching, but I can not seem to find an actual answer. I have a list of services as child pages under "Services". I can output the services just fine, but I cant wrap my head around how to group them "alphabetically" like: Services A - Service "A" 1 - Service "A" 2 - Service "A" 3 B - Service "B" 1 - Service "B" 2 - Service "B" 3 C - Service "C" 1 - Service "C" 2 - Service "C" 3 Has anyone achieved this type of functionality before?
  4. How do you guys sort according to the order of page listing? My template is sort order none, so I assume it would return according to order of page listing.
  5. Hi all! I have a little problem here. I want to sort a list of addresses by streetname and then by number. First, I just had a field "prod_objekt" (address) containing both and then have a foreach loop like this: $pages->get('/produzenten/')->prod_repeater->sort('prod_objekt') as $produzent. Unfortunately, this would not sort by streetnumber if I had the same streetname but multiple numbers. Now, I thought I could sort by two fields. prod_object (adress) first and then by prod_hausnummer (streetnumber). But I just don't know the code for it. I tried this: $pages->get('/produzenten/')->prod_repeater->sort('prod_objekt.prod_hausnummer') as $produzent, but it wouldn't work. Any ideas on how to solve this? Thanks for your help Roli
  6. Hello, I'm facing an issue with my page fieldtype. Pages appear in the order they were created although I'd like to see them sorted in alphabetical order (by title). The pages are well-sorted in my tree, but in that particular Page fieldtype (on another page), I can't find any place where I would decide on what field I can sort them. Am I missing something here ? Let me know if I'm not clear enough in my explanations. Thanks in advance for a clue
  7. This is a pretty typical thing. Open a page, it does a $pages query, finds 112 things and I list them on the page. There is pagination too, 20 per page. I want a sort dropdown box so the visitor can change alpha sort or whatever other sorts and filters I eventually use. My first thought is to just refresh the page with a url query like "page/?sort=az" and then adjust the query in the template code. But to do this, it will require a page refresh, which means the sort box goes back to its default, and not sure how it effects pagination. If I do a page refresh, I'll have to keep the sort settings in the session or something, to make sure I always apply correct sort on page load. But at the same time, I've already got the $pages array, it would be much nicer to shuffle it and update the page without a page refresh, rather than run the query over and over again. But then again, the pagination buttons already cause page refreshes, so that is already happening anyway, unless I convert the pagination buttons to also be no-refresh somehow. I figure this is a very common problem, to paginate results and give users a sorting/filtering option. What is the common methods for handling it? Session, url query, ajax? If I just add the sort to the url query, how do I make that work in the pagination links?
  8. I need to sort results by title ascending, and title includes special characters (croatian letters). The problem is that results are sorted but not 100% correct: e.g. $authors = $pages->find("template=author,sort=title"); Cavali Cavilon Čavlović Cesare ... You see intruder (bolded), it looks like sort engine treats letters C and Č as same ones. I'm not sure that this is Processwire related, but maybe API has solution for this kind of behavior? I have UTF-8 page content type .
  9. Hi all! I want to sort child-pages by two fields but I don't know if it is possible within one selector or if I have to make two separate queries <?php foreach ($page->children('sort=checkbox, sort=-number') as $child): ?> I want to keep 'checked' pages on top and sort them and all following by the 'number' field. The 'checkbox' field is a
  10. I'm having trouble with sorting by repeater count. We have awards given to each work and the awards are in a repeater. Doing "sort=-awards.count" However it isn't working. Anyone got any ideas?
  11. I use pagination modul. I have a field which has born year info. But I put the years with sign "-" for BC (Before Christ). my selector sorts like as text. -384, -4, -412 .. it must be: -412, -384, -4 selector: $pages=$page->children("limit=60, sort=date_field"); I want to order my pages like as php natsort function. thank you.
  12. Dumb question coming up. I can't get sorting to work. I show child pages (posts) of a parent page (news) on the homepage with this in the template: $news = $pages->find("template=post"); foreach($news as $post) { ... Sort order setting in the template or page is apparently ignored. The sort order is correct in the admin area, but shows up wrong on the home page. What am I missing?
  13. 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.
  14. This must be simple, however, I couldn't figure out how to do it. I got this structure in the admin tree: Page 1 [Template A] Children 1-1 [Template B] Children 1-2 [Template B] Children 1-3 [Template B] ... Page 2 [Template A] Children 2-1 [Template B] Children 2-2 [Template B] ... Page 3 [Template A] Children 3-1 [Template B] ... What I want in the front end, is this sort order: Children 1-1 Children 1-2 Children 1-3 Children 2-1 Children 2-2 Children 3-1 Plus, the order should depend on the order in the admin tree. So, if I move Page 3 on top of the tree, the children of Page 3 should appear first. I tried this, but the order seemed to be random (without a connection to the order in the admin tree): $pages->find("template=B, sort=sort"); I also tried this, and again I got a random looking order: $pages->find("root.template=A, sort=sort"); Do you have any idea? Thanks, Nils
  15. Hi, I'm sorry if this has been adressed before but I couldn't find anything about it. I'm pretty new to processwire but not to php or object developpment. I'm working on a blog and the request was to add a custom date field on articles that allows the user to override the "date" associated to the article. It's basically a publish date. If set, that date is used to sort the article and also if the date is in the future the article will not be displayed on the website. Here is the selector I used to sort my articles list before: $pages->find('template=news, sort=-created, limit=4'); and here is how I do it now : $pages->find('template=news,!news_date>today, sort=-created|-news_date, limit=4'); The only issue is that the sort does not sort a big mashup of all the dates regardless of whether it's in "created" or "news_date" but it sorts one and then the other. So what I get is a list of dates like this 02 jul 2015 (news_date) 15 Jul 2014 (news_date) 2 Dec 2014 (created) 1 Nov 2014 (created) The news_date list is on top of the created list. Do you know how I could achieve this? Thanks a lot
  16. hi. i have a selector like this: $result = wire('pages')->find("template=xx, field_x=439|417|456|402"); now i need the $result sorted exactly like the values are commited in field_x. How to do this? thanks, martin
  17. I have a PageTable field that is updated via a custom module. Pages are updated by deleting them then re-adding but crucially need be re-added in the same order in the PageTable field. If I re-add pages, they go to the bottom of the field (it's a manual drag n drop setting). Is there a way to re-add where the page was previously? Or at the very least I need to maintain the first page in the field. It has a checkbox ticked if it's first so the re-added page could use that to test whether it needs to go first. I just don't know how to set the order of pages in a PageTable field via the api. Any help here much appreciated.
  18. Hello, on a brandnew 3.0.35 install, I get wrong results for $page->sort. My structure is like Home -level1-1 -level2-1 -level2-2 -level2-3 -level1-2 -level1-3 When I do foreach($homepage->children as $child) { echo $child->sort; } It gives me: 3, 4, 5 where it should be 0, 1, 2. When I loop through the children's children, the values are correct foreach($homepage->children as $child) { foreach($child->children as $ch) { echo $ch->sort; } } returns 0, 1, 2. On level1 there never where more than 3 pages. So I don't know why it possibly could be starting with 3 instead of 0. Is there any way to recreate the sort index? I tried moving level1 pages around in admin but that didn't change anything. EDIT: I also tried $homepage->children('sort=sort'). Same results.
  19. 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 }
  20. 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.
  21. 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?
  22. Hello all, My page has a lot of images. I created a gallery_image field to upload and display them. Unfortunately they are sort of unordered in the backend, though the filenames are numbered sequentially. I understand that this reflects the order of finished uploads. I figured out how to sort them on the frontend, but is there a way to do the same in backend? I guess this HookAfterPagesSave.module found here https://processwire-recipes.com/recipes/extending-page-save-process/ might do the trick but I'm too new to processwire and too unexperienced in coding to see what code to write. Anyone can help? Thanks in advance Hanna
  23. 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!
  24. 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
  25. 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
×
×
  • Create New...