Jump to content

Robin S

Members
  • Posts

    4,928
  • Joined

  • Days Won

    321

Everything posted by Robin S

  1. It won't be a repeater exactly but I can do something that achieves a similar result. Bit busy right now but will update the module over the next few days.
  2. @Nukro, did you solve the issue of the number of items on the last page of pagination? For example, if you make setTotal(50) and limit=7 and your find() actually finds more than 50 pages, then the second to last page will have results 43-49, meaning you want the last page to have only one result. But it will instead show 7 results giving you 56 results in total instead of the 50 you want. I played around and this seems to solve that: $limit = 7; // could be set from a field in your page $items = $pages->find("has_parent=1, limit=$limit"); // whatever selector, this was just for testing $total = min($items->getTotal(), 50); $items->setTotal($total); $remainder = $total - $items->getStart(); if($remainder < $limit) { $items->removeItems(range($remainder, $limit))->setTotal($total); } $start = $items->getStart() + 1; $end = $items->getStart() + count($items); echo "<p>Showing items $start - $end of $total</p>"; echo $items->each("<p>{title}</p>"); echo $items->renderPager();
  3. They really are the same thing: https://processwire.com/api/ref/wire-array/append/ https://github.com/processwire/processwire/blob/36984e4a057268b7a45b848e1b3b6ee757583459/wire/core/WireArray.php#L956-L959
  4. I think setTotal() is something that only applies to the pagination calculation. It doesn't place a hard limit on the results from the find() - that has as many items as there are matching results. So the results still have 1000 items or whatever, and setTotal() just tells the pager to stop at 100. Easy solution is to make your total evenly divisible by your items-per-page limit.
  5. How about: $items = $pages->find("template=event, limit=10")->setTotal(100); // output items here echo $items->renderPager();
  6. Do you have debug mode on? Any PHP notices? I think I had an issue a while ago where a PHP deprecated notice was interfering with with the tree AJAX response.
  7. I gave an example of how to do this in your other thread. You use a hook on MarkupSimpleNavigation: $nav = $modules->get('MarkupSimpleNavigation'); $nav->addHookAfter('getItemString', function($event) { $page = $event->arguments('page'); if($page->parent->id == 1) { // you can perform any test you want on $page $event->return = "<a href='#{$page->name}'>{$page->title}</a>"; // you can return any markup you want here } });
  8. This is the same as what @LostKobrakai showed in post 2: append() is identical to add(), and adding a page ID to a PageArray achieves the same as adding a Page object. The objective is to get the parents of the items in the first PageArray.
  9. I think the easiest way to do this is with Javascript/jQuery. Not too hard to write a script for this from scratch (that's what I've done in the past) but Google reveals a nice looking plugin that does it all for you: http://renaysha.me/anchorific-js/
  10. Hi @horst, Do you mean a mean the access to the page is blocked, or access to files stored in a files/images field on the page? For the page itself I would think you'd use role-based access, or just do not give the page's template a template file. But you would have thought of this already so maybe you need something else? For the files you can enable $config->pagefileSecure and then do not give the guest role access to the page. See the blog post and the $config docs. Also, there is the FieldtypeSecureFile module.
  11. To test it you'd need to set the inputfield to Hidden, create a new page, then check the value as described above. If it's an existing page that was previously edited when the field was set to Open or Closed (i.e. anything that actually rendered the inputfield) then the value will remain populated even after you change the inputfield to Hidden. That's because changing the inputfield to hidden wouldn't delete field data from the DB.
  12. 1. You can get the field value with $page->my_datetime and log it, dump it with Tracy Debugger, or echo it on the frontend. 2. You can check the database table for the field in PhpMyAdmin or similar.
  13. Are you sure of this? I tested it quickly and it seems to not populate the field when set to hidden. If the inputfield is hidden then I expect its render method is never called so no default value is entered into it. Is there a difference between what you're wanting to do with this field and the "created" property that exists by default when adding a new page? Because if your field is hidden then nobody could ever edit it so it would always remain identical to the created datetime. So could you just sort your pages by "created"?
  14. Got it, thanks. And your interpretation of those movies clearly goes much deeper than mine
  15. Sounds interesting. Can you give an example of how that could be useful? Maybe something like a Friends field? On page "Bob", "Sue" is added to Friends - so on page "Sue", "Bob" is automatically added to Friends. Just trying to think through the different use cases for the module.
  16. Looks like the page was deleted on 16 August for reasons of "Searches are finding only PR and trivial links, nothing at all summarizes to actual substance." Which is bizarre as a Google search for ProcessWire would obviously turn up a large number of results. Then the page was restored (by the same user who deleted it) on 1 October without explanation as to why, but only restored to Draft status.
  17. Probably not: I answered my own question in the next post: The situation @Wanze replied to is a little different - not an order of page IDs but an order of values to match a field against.
  18. When exporting web images (assets from design mockups) I follow this guide and it works great: https://www.viget.com/articles/the-mysterious-save-for-web-color-shift Working Space: sRGB Proof Setup: Monitor RGB Proof Colors: On (doesn't affect export - just ensures you see the same colour in Photoshop as you will in the browser) Save For Web Embed Color Profile: unchecked Convert to sRGB: unchecked
  19. Is it possible to use a selector to find fields that have a given textformatter applied? I tried... $flds = $fields->find("textformatters=TextformatterHannaCode"); ...but the textformatters property is an array so I get an array to string conversion error. So a broader question would be: is it possible to use a selector to match inside a property that is an array? For the textformatter, is there a more efficient way than just iterating over $fields? $flds = []; foreach($fields as $field) { if( is_array($field->textformatters) && in_array('TextformatterHannaCode', $field->textformatters) ) $flds[] = $field; }
  20. I think that's just a coincidence if you add several pages one after the other without reordering them in the field. But because a page that's in a PageTable field can reside anywhere in the page tree there could be other pages added (that have nothing to do with the PageTable field) which would affect the sort property of the page. Intentional, because there are really two sort values - the sort property that belongs to the page itself (the tree sort) and the sort that belongs to the PageTable field. This is in the PT database table but doesn't seem to be passed though as a property of the pages when you get them via the PT field. @alexcapes The order of the field is set according to the order of pages in the PageArray (or array of page IDs) when you save it to the field. For example: $page->setAndSave('my_pagetable', array(1009, 1002, 1007)); // an array of page IDs // or $pa = $pages->find("template=my_template, sort=title"); // create and sort your PageArray however you like $page->setAndSave('my_pagetable', $pa); You could also do things like get the existing PageTable PageArray and then add pages using methods like insertAfter() But are you sure you have to delete and recreate pages? You could keep the existing pages and change just about any property of them without actually deleting them. Maybe explain the whole process of what you're doing and someone may be able to suggest a different approach.
  21. I think "sort" is the sort order of the pages as they appear in the tree, which may be different than the order they appear in the PageTable field.
  22. Nice one! But just a small thing: you set $search to an empty WireArray and then immediately re-set it to an empty array: $search = new WireArray; $search = array(); You only need the latter.
  23. +1 (I hate auto focus... ) Just wanted to add that I find the autofocus of the filter box specifically on the modules listing quite useful. I'd much rather type than scroll.
  24. Did you do this bit...? But in any case if you update to LimitPageTable v0.0.3 linked in my first post above it adds a config option to choose which value you want to match against so no editing of the module is needed now.
×
×
  • Create New...