Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/04/2023 in all areas

  1. Add support for the Latte templating language to the Template Engine Factory. Available on the module directory and on GitHub. The latest version uses Latte v3. Configuration The module offers the usual the following configuration: Template files suffix The suffix of the Latte template files, defaults to latte. Default layout file Layout that all views will extend from unless overwritten. Provide ProcessWire API variables in Latte templates API variables ($pages, $input, $config...) are accessible in Latte, e.g. {$config} for the config API variable. Simplified path resolution Enable Blade-style dot syntax for directory traversal, e.g. partials.navigation instead of ../../partials/navigation.latte Auto refresh templates (recompile) Recompile templates whenever the source code changes.
    4 points
  2. You have to read carefully. What I showed was the syntax for saveCustomField() method. You now posted the one for addCustomFieldToPageEditForm() - that are two different things. saveCustomField hooks into Pages::saveReady, therefore the $page is available as the very first argument of the HookEvent: $event->arguments(0) or $event->arguments('page') addCustomFieldToPageEditForm on the other hand hooks into ProcessPageEdit::buildForm, therefore the edited $page is available as $event->object->getPage() Your solution is fine as well, but it will only work for situations where the page id is available as a get parameter. So I'd recommend you read again my post/video about hooks here: https://processwire.com/talk/topic/18037-2-date-fields-how-to-ensure-the-second-date-is-higher/#comment-158164
    2 points
  3. Ah and I'm not sure if that is a good idea. wire('page') is the current PW page. Did you check if that is really the correct page and not the page with id 10 that is responsible for rendering the page edit form?? I'd better get the edited page from the HookEvent: $page = $event->arguments(0);
    2 points
  4. Adding custom PHP code to any page in the backend is extremely easy as well (if you know how) ? <?phhp // in site/ready.php $wire->addHookAfter("ProcessPageEdit::buildForm", function ($event) { $form = $event->return; $page = $event->object->getPage(); if ($page->template != 'home') return; $existingField = $form->get('title'); $out = "Show 5 random pages:"; $pages = $this->wire->pages->find("limit=5, template=basic-page, sort=random"); foreach ($pages as $p) { $out .= "<div><a href={$p->editUrl}>{$p->title}</a></div>"; } $newField = [ 'type' => 'markup', 'label' => 'foo', 'icon' => 'check', 'value' => $out, ]; $form->insertAfter($newField, $existingField); });
    2 points
  5. thanks @bernhard, yes I noticed that later on. I managed to get the module to serve my needs, it's here: https://github.com/dtjngl/MenuAllocator I (re)watched your hook-tutorial, it's interesting but I doubt it can help me in this very use-case since I do not really populate fields on the page and the fields in question are rendered at runtime (by a another hook), so I had a hard time saving the values to the page (luckily there's ->meta). I'm not sure if this is the best approach but it works. @everyone, please give it a try, I'd love to get feedback.
    1 point
  6. @Jim Bailie, I've released v0.2.0 of Files Rename Replace which will now retain the uploadName property when a file is replaced.
    1 point
  7. public function ready() { $this->addHookAfter('ProcessPageEdit::buildFormContent', $this, 'addCustomFieldToPageEditForm'); // ... } public function addCustomFieldToPageEditForm(HookEvent $event) { $page = $event->arguments('page'); // null // ... } ;( EDIT: $id = $this->input->get('id'); // frontend page object id $page = wire('pages')->get($id); // frontend page object ?
    1 point
  8. Another option might be the RuntimeMarkup module.
    1 point
  9. 1 point
  10. in the module or module config/settings, I want to define an array of "menus". Then, on every page in the page tree, except on pages inside "Admin", I want to render an array of checkboxes (InputFieldCheckboxes), one for each entry in the predefined "menus"-array. When the content manager edits a page they will see these checkboxes, and one or more before saving the page will naturally be saved somewhere, ideally as a property of the page. When creating the menus in the markup (e.g. top menu, footer, sidebar, you name it), one should be able to select the pages according to the values set for said field on the pages. I'm not sure if creating adding a field and adding it to a fieldgroup and template is necessary (also this approach is quite prone to errors, I have to consider __install() and __uninstall() etc.), I managed to accomplish something very simliar with a different module (https://github.com/dtjngl/simpleSearch/blob/main/SimpleSearch.module.php), the difference was, that one renders a text field on each template and when editing a template, the entered value gets saved to the template object. Works like a charm. Thanks for you input!
    1 point
  11. Also want to point out how the video clearly shows that if you write PHP, a very fast and expensive sports car will show up in your garage. You can't argue with that, it's right there next to his big reaction face.
    1 point
  12. Happy 1st of September! Now that we've got the new main/master version out and running smoothly, I've been catching up with some client work this week. I'll need to do some of that next week too. But we'll also be fine tuning the core and fixing anything that comes up in issue reports. We may have have another master version out with these kinds of minor updates before digging into more major updates, feature requests and PRs on the dev branch this month. If you've not yet upgraded to 3.0.226 yet, I'd encourage you to give it a try. So far all reports have been positive and I've not heard of anyone running into any upgrade issues yet. Thanks and have a great weekend!
    1 point
×
×
  • Create New...