Jump to content

Robin S

Members
  • Posts

    5,039
  • Joined

  • Days Won

    340

Everything posted by Robin S

  1. Getting the containing page seems like it will be difficult because the page isn't added to the PageTable field until after it is saved and published, so a hook on these won't work. What is the reason for the "media_wall_work_ref" field? Perhaps there is another solution that can achieve the same.
  2. Hi @adrian, I'm getting an issue where bd() causes an error when used in a ready.php hook triggered from a PageTable field. For instance, if I have saveReady hook, and the page is saved from the "Add New" procedure in PageTable I get: Error: Uncaught Error: Call to undefined function bd() in ...\site\assets\cache\FileCompiler\site\ready.php:46 Edit: False alarm. I saved the module config and the issue is gone.
  3. If that were so PW wouldn't work full stop.
  4. include ? ob_start(); include 'partials/sharedtemplates/signup-form-formbuilder.php'; $out .= ob_get_clean();
  5. @alexcapes, @szabesz, I've updated the module to allow the limiting of multiple PageTable fields and/or multiple templates for the same field. You can now also limit PageTable fields that only allow a single template. Because the module config options have changed I'm afraid you'll need to re-enter your config if you are upgrading from a previous version. I made a thread for the module over here which has a link to the GitHub repo.
  6. LimitPageTable A module for ProcessWire CMS/CMF. Allows limits and restrictions to be placed on selected PageTable fields. Usage Install the LimitPageTable module. For the PageTable field you want to limit, on the "Input" tab include "template" or "template.label" in "Table fields to display in admin". You can skip this step if your PageTable field only allows a single template. In the module config, fill out the fields in the fieldset row: PageTable field you want to limit Role that restrictions will apply to Template you want to limit (only needed if your PageTable field allows more than one template) Field you have included in the "Table fields to display in admin" setting (only needed if your PageTable field allows more than one template) Limit Option to prevent drag sorting of items (affects all rows regardless of template) Option to prevent trashing of items (affects all rows regardless of template) Option to disable all "Add" buttons for any template You can add rows as needed using the "Add another row" button. If you are using translated text for the default PageTable "Add New" button then enter the translation in "Text for default 'Add New' button". Please note that limits and restrictions are applied with CSS/JS so should not be considered tamper-proof. http://modules.processwire.com/modules/limit-page-table/ https://github.com/Toutouwai/LimitPageTable Module config: Demo showing PageTable limited to 2 pages using 'Blank' template:
  7. I'm not sure what's causing your issue, but does it make a difference if you save only the repeater field rather than the whole page? $m->save('gruppenzuordnung');
  8. I think you're looking for OR groups: https://processwire.com/api/selectors/#or-groups $allConcerned = $pages->find("template=player, team.name=$selectedTeam, (people.count>=3), (places.count>=3)");
  9. @Speed, to start learning about hooks have a read of this documentation page. It's not a simple concept to grasp so don't worry if you don't understand all of it at first. You also need to know a bit about Object-oriented programming terms like class and method. Regarding MarkupSimpleNavigation, first understand what it is doing: it takes all the pages in your website (or all the pages you give it) and loops over them, looking at each page (item) one at a time and outputting some markup for that page. It has some markup that it uses by default but we can override that using a hook. getItemString() is a method in the MarkupSimpleNavigation class - you can get some idea what it does from it's name. It gets the string (markup) for the item (the page in the loop that MSN is currently looking at). In the hook example I gave we are saying to MSN "if the item you are currently looking at is a direct child of the Home page, don't output the default markup but output this special markup instead". Methods can have arguments (variables) that are used inside the method. When you hook a method you can use those variables in your hook, which can be handy for what you want to achieve. To know what arguments/variables are available you need to look at the method code. If you look at the code for getItemString() you can see there are two arguments: $tpl and $page. For this hook we want to get $page (the item MSN is looking at) so we can test it to see if the page is a direct child of the Home page. $page->parent->id doesn't mean the home page. What this says is "for the parent of this page, get the ID property". Each page has a unique ID - one way you can see the ID of a page is to hover the "Edit" link for a page in the tree and look at the link URL. You'll see something like ".../page/edit/?id=1234". The Home page always has an ID of 1 (there might be some very rare exceptions but we won't worry about that). So in the hook we say if the page's parent has an ID that equals 1 then the page is a direct child of the Home page so output this special markup.
  10. 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.
  11. @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();
  12. 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
  13. 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.
  14. How about: $items = $pages->find("template=event, limit=10")->setTotal(100); // output items here echo $items->renderPager();
  15. 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.
  16. 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 } });
  17. 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.
  18. 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/
  19. 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.
  20. 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.
  21. 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.
  22. 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"?
  23. Got it, thanks. And your interpretation of those movies clearly goes much deeper than mine
  24. 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.
  25. 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.
×
×
  • Create New...