Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by bernhard

  1. Yeah, feel free to grab it here and improve/maintain it for the future πŸ™‚ https://github.com/baumrock/rockhitcounter
  2. When using DDEV you can check if everything works with your specific installation just by changing a value in .ddev/config.yaml of your project. Here are all the possible database types that are supported: https://ddev.readthedocs.io/en/latest/users/extend/database-types/ Yes, you need to install DDEV first. But you'll never ever have these kind of problems or fears any more. Locally I'm on MariaDB 10.6.12 InnoDB on most projects and have no issues.
  3. I'm using frontend editing all the time. Suddenly on my new project when I tried to copy and paste several regular text-field contents: I ended up with markup in my fields: So I always need to hit the edit icon to edit it in the modal which shows the backend inputfield and there I can safely copy&paste like this: Any ideas why this would happen? I'm not sure why I didn't experience this behaviour so far. Maybe it's an update of something?
  4. Glad you got a working solution, but what you said is not 100% correct πŸ™‚ I used $page->template != 'something' and this will work. But it will only work if you use the "not equal" (!=) operator. It will NOT work, if you use the "not identical" (!==) operator! Check this out: So if you use the two letter comparison (== or !=) then PHP will try to convert your $page->template into a string and ProcessWire will be smart enough to use the template's name. So you'll end with a string == string comparison and you should get the desired result. If you use a three letter comparison (=== or !==) then PHP will not convert $page->template and object === string will always be FALSE and object !== string will always be TRUE. Hope that makes sense πŸ™‚
  5. There seems to be a module that does what you need: https://processwire.com/modules/restrict-tab-view/ (at least for the tabs! I haven't used it though). But you can do both quite easily with two hooks in /site/ready.php - unfortunately you can't do everything in one hook because you need to hook "before" and "after" the buildForm(Content): <?php // hook to make the title field non-editable $wire->addHookAfter("ProcessPageEdit::buildFormContent", function ($event) { // get the page being edited $page = $event->process->getPage(); // check if the page has the desired template if ($page->template != 'your-template') return; // check if the user has the desired role if (!$this->wire->user->hasRole('admin')) return; // get the form that was built in buildFormContent() method $form = $event->return; // make the title field non-editable $f = $form->get('title'); $f->collapsed = Inputfield::collapsedNoLocked; }); // hook hide the settings tab $wire->addHookBefore("ProcessPageEdit::buildForm", function ($event) { // get the page being edited $page = $event->process->getPage(); // check if the page has the desired template if ($page->template != 'your-template') return; // check if the user has the desired role if (!$this->wire->user->hasRole('admin')) return; // set noSettings property dynamically $page->template->noSettings = 1; });
  6. Hi @olafgleba thx for sharing and congrats for the great result πŸ’ͺ😎 Not sure if I understand that correctly, but wanted to add that you might not need an additional field here. Not saying an additional field is bad, though πŸ˜‰ You could either access the user that created the page via $page->createdUser or, if you need a different logic you could use $page->meta('youruser', 'yourvalue') instead of adding a field to that page and then use that for storage. Have you thought of using url hooks or url segments to show your content with custom logic at a custom/different location than the original url? You might save you from the hassle of keeping everything in sync then.
  7. With RockPageBuilder this would look like this: You can easily create new blocks by clicking on the plus after the last block and every block consists of one PHP file for the business logic (if needed), one PHP/LATTE file for the output markup and optionally one .less file for the stylings: If you do it smart then you can even reuse these blocks in other projects just by copy and pasting these files πŸ™‚ Compared to RepeaterMatrix which would also be a possible solution RockPageBuilder comes with great integration and a complete UI for frontend editing: So instead of using $block->headline to output the headline of the block you simply use $block->headline() and your headline will be frontend editable!! For non-text fields you can double click anywhere and the editing interface will be loaded in a modal. 😎 I've not done a single website without that module for a very long time πŸ™‚ It will be 49€ for a single site for early birds. I'm working on the docs and on the webshop at the moment, but there are already several people from the forum using it for real projects, so if you are interested just write me a PM or signup to rock monthly to get notified when sales start πŸ˜ŽπŸš€ https://www.baumrock.com/rock-monthly/
  8. I thought that repeater pages have their own template, sorry. If that's not the case then just modify my hook to check the page's parents: Here the $page is a repeater item. You can inspect its parents like shown in line 1 and you can add something like shown in line 2 into your hook to only fire that hook that overrides the title if the parents have your repeater parent page. If not, then early exit of that hook. <?php $wire->addHookProperty("Page::title", function ($event) { $page = $event->object; if(!$page->parents->has("name=for-field-157") return; $event->return = $event->object->headline; });
  9. Ah, sorry - that's what I already showed in my previous post! Just find out the template of your repeater items and use the hook that I posted.
  10. If you compare both approaches it would be interesting if you share your findings. https://processwire.com/blog/posts/debugging-tools-built-in/ (Debug::timer) might be helpful and memory usage could also be interesting.
  11. Note that this does NOT help with scalability issues. Quite the contrary. It will keep two page fields in sync but it will store the data twice. So if you have lots of pages, you'll make your issues even worse.
  12. I'm thinking of removing ALFRED from RockFrontend. Is anybody at all using it in any projects??
  13. I guess the module uses something like $page->get('title|id') for the labels and since your page has no title field it falls back to the id. You can easily overwrite the "title" property of your page via hook! In this example I overwrite it for the "repeater_rpb_textgrid_items" template and set it to display the field "rpb_textgrid_headline" instead of "title": <?php $wire->addHookProperty("Page(template=repeater_rpb_textgrid_items)::title", function ($event) { $event->return = $event->object->rpb_textgrid_headline; });
  14. How many documents? How many users? If you only have a limited number then a simple page reference field would be all you need. Just add a field "readby" to your documents page and add users to that field via API. You just need to make sure that you don't have too many pages stored in the page reference field. So if you have many documents but just a few users add the page field to documents. If you have many users but just a few documents add the page field to the user template and add read documents to the field. If you have many documents and many users go with the custom table solution that I showed here:
  15. I'm quite sure you did, but just in case: Did you check if there is a plugin that can fix your issue? πŸ˜„
  16. 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
  17. 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);
  18. I think you are just missing this after $field->description = ... $page = $event->object->getPage(); $field->value = $page->meta('custom_text_field'); ... and maybe some sanitisation in saveCustomField() πŸ˜‰
  19. 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); });
  20. I've just tested this: $home->of(false); $home->rockfrontend_favicon->add(__DIR__ . "/Test$$$.png"); $home->save(); bd($home->rockfrontend_favicon->uploadName()); Which resulted in this: So that confirms that uploadName() does not work for API added files.
  21. I've added your example to the mentioned issue: https://github.com/processwire/processwire-requests/issues/56#issuecomment-1704363956
  22. How did you upload the file via api? Can you give a quick example to reproduce the issue? If you do that and post it to this issue and mention Ryan I guess chances are high that he will fix this quickly. At least I suggested the uploadName feature on Feb 16 and he implemented it on Feb 17 πŸ˜„ Maybe he just didn't think of API uploads.
  • Create New...