Jump to content

Robin S

Members
  • Posts

    5,009
  • Joined

  • Days Won

    333

Everything posted by Robin S

  1. That raises the question: why aren't the debug and quick-tree icons shown in Chrome PC? An AOS issue or core issue? Edit: they're not visible in IE11 either. Weird.
  2. It seems to be browser-specific on PC. In Chrome the attributes are correct but in Firefox they're wrong.
  3. It's not working quite right in Firefox. The data-url and data-editurl attributes are for the neighbouring breadcrumb item. In the screenshot below the Home item has the data- attributes for the "Four" page.
  4. Looks like I didn't test my module for single Page fields. Will get that sorted in an update soon. In the meantime just set the 'featured_on' Page field to 'multiple' and it should work.
  5. I don't know that it will, because the default behaviour for removing pages from a PageTable field involves marking them for deletion (uses JS) and the deletion takes place when the container page is saved. Pages don't disappear from the inputfield when marked for deletion, as opposed to the way pages appear when they are added. But I can think of some alternatives. Seems like what you want is to have some featured Quote pages: you mark a Quote page as 'featured' when editing that page, and when editing the Home page you can see all the Quote pages that were marked 'featured'. Option 1: use a 'featured' checkbox on the Quote template. Use a RuntimeMarkup field on the Home template to list all the featured pages, maybe with a link to Edit Page for each featured Quote to make it easy to 'unfeature' a page. Option 2: Use the ConnectPageFields module. Create a 'featured_quotes' Page field on the Home template (multiple, allows pages using Quote template, uses AsmSelect inputfield) . Create a 'featured_on' Page field on the Quote template (single, allows pages using the Home template, uses Checkboxes inputfield). Link these Page fields in the ConnectPageFields module. Now you can add/remove featured Quotes when editing the Home or a Quote page.
  6. @tpr, I'm not loving the bold styling applied to active/open items in PageList instead of the default yellow background. Can you make this optional please?
  7. BTW, to update pages after they are added to a PageTable field I found one approach, and that is to hook the field save done in InputfieldPageTableAjax.php. The reason you want to hook this for added pages rather than the save of the container page is that the editor could add pages to the PageTable field and then leave Edit Page without saving the page, meaning your hook wouldn't fire. You have to place the hook in init.php - this hook doesn't fire for InputfieldPageTableAjax.php if you place it in ready.php (would love to know why). $this->pages->addHookAfter('saveField', function($event) { $page = $event->arguments('page'); $field = $event->arguments('field'); if(is_string($field)) $field = $this->fields->get($field); if($field->name !== 'my_pagetable_field') return; $new_value = $page->{$field->name}; $pages_added = $new_value->getItemsAdded(); // here save something about $page to a field in $pages_added }); To update pages after they are removed from a PageTable field you would hook Pages::saveReady for the container page and look for changes to the PageTable field, doing something similar to this section of ConnectPageFields.
  8. Unless you need the reference number inside PageEdit for some reason (e.g. an inputfield dependency, and for that there are workarounds using RuntimeMarkup or FieldtypeReference), it should be possible to get the reference using the API in your template. You either get the page via the container page's PageTable field, or in the page's template you do similar to what you showed in your first post: $container_pages = $pages->find("my_pagetable_field=$page");
  9. A ProDevTools request: A module that puts PW into "record mode", where template/field additions and changes (via admin or API) are recorded in some way. The idea being that a live site could be cloned to a dev environment, changes made and recorded, and then the changes "played back" on the live site to apply them. I use an exported profile for this, which includes all the modules, templates, settings, etc, that I like to have as a starting point for new projects. Exported profiles don't include config.php tweaks, but if you use the ProcessWireConfig module (why isn't this great module in the directory?) then restoring your customised config settings only requires copying config.json to /site/assets/config/. The only thing missing then is user accounts.
  10. 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.
  11. 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.
  12. If that were so PW wouldn't work full stop.
  13. include ? ob_start(); include 'partials/sharedtemplates/signup-form-formbuilder.php'; $out .= ob_get_clean();
  14. @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.
  15. 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:
  16. 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');
  17. 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)");
  18. @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.
  19. 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.
  20. @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();
  21. 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
  22. 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.
  23. How about: $items = $pages->find("template=event, limit=10")->setTotal(100); // output items here echo $items->renderPager();
  24. 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.
  25. 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 } });
×
×
  • Create New...