Jump to content

Pete Jones

Members
  • Posts

    88
  • Joined

  • Last visited

Everything posted by Pete Jones

  1. OK - looks like I might need to dust off my OOPHP books! Thanks LK.
  2. I've been looking at that. I think we should be able to change the output to a <select> list and handle page changes with a bit of JS. If we wanted to take this further, are there any 'demo' module extensions that we could look over? A kind of 'hello - extended- world'?
  3. I'm just looking at trying to modify the output of the renderPager function. Instead of <li> for the page numbers, we need a select menu. Is it possible to modify the HTML that is returned or will I need to write my own function? Historically I would have used some form of override (Joomla) or inheritance to achieve this. What is the best way to 'build' on the PW core rather than rewrite it? What we're looking to achieve is have a dropdown rather than the intermediary numbers e.g. 1 ~ DROPDOWN ~ LASTPAGE
  4. Hi, sorry to bring this up again. After looking further down the pages, we can see some improper ordering. We are getting pages that should be found with this selector "template=horse-note, sort=-h_notes_last_comment" appearing before pages from this selector "template=horse-note, $session->unread_by>0, sort=-h_notes_last_comment"
  5. Erm, no. But only to check you were paying attention. I've done that and it now appears to be matching the order of the old query. Good work LK! Can we buy you a beer? One thing I do need to do now is to create pagination. If I'm now only returning the results I need for the current page, can I still work out how many pages I need in total?
  6. Okay, so I've now added the 'NoDuplicates' version into my page. I'm getting the same results as before, i.e. it's fine with the first 2 selectors, but the third one breaks it. include 'src/Paginator.php'; include 'src/PagesPaginator.php'; include 'src/PagesPaginatorNoDuplicates.php'; I feel it's 99% there though, and so much quicker than the previous query we were using.
  7. The ordering is fine with the first 2 selectors in the paginator. The third one breaks the ordering for some reason. So this is fine: $notes = $paginator(array( "template=horse-note, h_notes_comments.count>0, h_notes_comments.$session->unread_by>0, sort=-h_notes_last_comment", "template=horse-note, $session->unread_by>0, sort=-h_notes_last_comment" ), $pageNum, $limit); But this is out of order: $notes = $paginator(array( "template=horse-note, h_notes_comments.count>0, h_notes_comments.$session->unread_by>0, sort=-h_notes_last_comment", "template=horse-note, $session->unread_by>0, sort=-h_notes_last_comment", "template=horse-note, sort=-h_notes_last_comment" ), $pageNum, $limit); Is there any reason you can think of that the third selector would interfere with the ordering?
  8. Ah ok, we had a few issues with the ordering, prepending vs appending and also the order of the items in each selector. Will have a tinker with it.
  9. The search query returns has some specific ordering which we've been unable to create using a single selector. When the page first loads there are no filters applied so we are querying 6000 items (and counting). We need the pagination to work without having to query everything. Seems strange that the current results are not coming back in the same order as the previous query. Could it be that we are prepending the results rather than appending? What is the default order of the array?
  10. Just giving an update on this. We are getting results. Page load time is now 1 second cf. 9 seconds using the original code. The results are not in the same order though. We did have problems getting them into the correct order which is why we had do this: // create notes PageArray $notes_total = new PageArray(); $notes_total->add($notes_other); $notes_total->prepend($notes_unread); $notes_total->prepend($notes_with_unread_comments); Can we influence the order in $paginator?
  11. Indeed, many thanks for putting that together for us LostKobrakai. Looking at my original code, can I now do this? $result = $paginator(array( "template=horse-note, h_notes_comments.count>0, h_notes_comments.{$session->unread_by}>0, sort=h_notes_last_comment", "template=horse-note, {$session->unread_by}>0, sort=h_notes_last_comment", "template=horse-note, sort=-h_notes_last_comment" ), $input->pageNum, 15);
  12. I'm not sure I can do what we need with a single selector. The reason we ended up creating a pageArray was because we couldn't get the pages to be in the order we needed with a single selector. The refinement selectors are only used if the user chooses one or more of the filter options, so 99% of the time these won't be applied. We're grabbing all pages and then using 'slice' to grab the portion of pages for the current page. E.g., if the page number is 10, we want slice(9*15, 15) of the total pages. I know count is a lot quicker, but can't see how we can use that usefully here. Happy to take any advice though.
  13. We have a big selector which we have broken down into 3 chunks to return a list of notes (pages) with repeaters as follows. We also allow the user to filter the results. The problem we have is that the page currently takes nearly 10 seconds to process results. Is there anything we can do to improve the performance of this? I wonder if it would be worth bringing the filters into each of the find()s. I assume that caching here wouldn't work due to querystring parameters? $selector = "template=horse-note"; // Notes with unread comments (date order, most recent first) $notes_with_unread_comments = $pages->find("{$selector}, h_notes_comments.count>0, h_notes_comments.{$session->unread_by}>0, sort=h_notes_last_comment"); //echo 'Notes with unread comments ('.count($notes_with_unread_comments).'):<br />'.$notes_with_unread_comments.'<br /><br />'; // Unread notes (date order, most recent first) $notes_unread = $pages->find("{$selector}, {$session->unread_by}>0, sort=h_notes_last_comment"); //echo 'Notes unread ('.count($notes_unread).'):<br />'.$notes_unread.'<br /><br />'; // Read notes in date order (most recent first) that they were either added or that the last comment was made, whichever is most recent. $notes_other = $pages->find("{$selector}, sort=-h_notes_last_comment"); //echo 'Notes other ('.count($notes_other).'):<br />'.$notes_other.'<br /><br />'; // create notes PageArray $notes_total = new PageArray(); $notes_total->add($notes_other); $notes_total->prepend($notes_unread); $notes_total->prepend($notes_with_unread_comments); // FILTER // sanitize inputs $horse = $sanitizer->text($input->get->horse); $category = $sanitizer->int($input->get->category); $from_date = $sanitizer->text($input->get->from_date); $to_date = $sanitizer->text($input->get->to_date); $comments = $sanitizer->int($input->get->comments); // horse name if($horse) { $selector .= ", parent.h_name%=$horse"; } // note category if($category) { $selector .= ", h_notes_category_id=$category"; } // from date if($from_date) { $selector .= ", h_notes_last_comment>=".strtotime("$from_date 00:00:00"); } // to date if($to_date) { $selector .= ", h_notes_last_comment<=".strtotime("$to_date 23:59:59"); } // comments if($comments) { $selector .= ", h_notes_comments.count>0"; } // apply filter if($selector!='template=horse-note') { $notes_total = $notes_total->find($selector); } // slice PageArray according to pageNum $pageNum = $input->pageNum; $limit = 15; $start = ($pageNum-1)*$limit; $notes = $notes_total->slice($start, $limit);
  14. This should be extended to something like: function formatBytes($size, $precision = 2) { $base = log($size, 1024); $suffixes = array('', 'K', 'M', 'G', 'T'); return round(pow(1024, $base - floor($base)), $precision) .' '. $suffixes[floor($base)]; } echo formatBytes(24962496); // 23.81M echo formatBytes(24962496, 0); // 24M echo formatBytes(24962496, 4); // 23.8061M *Taken from http://stackoverflow.com/questions/2510434/format-bytes-to-kilobytes-megabytes-gigabytes
  15. Does anyone have a reference to what you can add as formatting parameters? I assume you can return MB, KB, GB without having to divide them manually?
  16. I'm using Netcarver's FieldtypeTime module and I'm trying to sort results by time (in 24hr format hh:mm) but the following doesn't seem to work. My time field is fde_racetime. foreach ($page->children("fde_date>$todaysDate,sort=fde_date,sort=fde_racetime") as $alldays) { foreach ($alldays->fde as $entry) { if ($entry->fde_declared == 1) { $section_main .= showFDE($alldays, $entry); } } } Would I need to create a specific sort condition? http://modules.processwire.com/modules/inputfield-time/
  17. Thanks Peter, Funnily enough, there is only minimal caching at the moment. We are intending to start caching a lot of the horse data now that the client has finally decided what they want (last minute brief changes)
  18. Interesting - would this be something that could be run as a scheduled job to check all fields and provide a report?
  19. We're recently completed a sizable project for Qatar Racing (www.qatarracingltd.com). This was a bespoke build pulling in a JSON feed of horses from a 3rd party. This feed was then incorporated into a members area where members could comment and reply on horses, effectively a full messaging app. Qatar Racing (www.qatarracingltd.com)
  20. Just had an issue with a failed data import which resulted in processwire failing to import a page under the correct parent. Ultimately we had to remove the parent and reimport it. Are there any database integrity checkers/orphaned item checkers available for PW which could flag up any problems?
  21. hmm ok must be something else then. Thanks LostKobrakai. If we wish to specifically control the order of the PageArray (using a key) should we need to add the key in or should the order of the PageArray remain unchanged when we add items?
  22. We have a fairly complicated sorting requirement where we are ordering by pages and then by the condition of a checkbox within a repeater, within each page. There are subsequent 2 sorting criteria that are applied. We have split the 3 sort conditions into 3 different selectors which we are then adding to a PageArray. When using $items->add($firstsortedarray) the sorting is ok, when we then add subsequent arrays the ordering of the overall array breaks. Is there a difference in the way ->add works compared to ->append?
  23. Hi Dean, I've seen this problem too. Does anyone understand why it's only looking at the first repeater item checkbox, and not all of them?
  24. Hi Ben, Can you check for a duplicate URL field in a repeater on import?
×
×
  • Create New...