Jump to content

Hans0L0

Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by Hans0L0

  1. Correction: I've tried that one too, but it's the same result as with 'wire()'.. that got it working! My mistake was writing '->$sanitizer' instead of '->sanitizer', also in the version with 'wire()' Thanks! ?
  2. Hi flydev, I've tried that one too, but it's the same result as with 'wire()'..
  3. Hey guys, I'm trying to generate a page name depending on another input field (checkbox) as a combination of title and an extra text field. So far, I've found this topic with an explanation how to hook after page save: So what I was trying is the following: /* ready.php */ $pages->addHookAfter('saveReady', function(HookEvent $event) { $page = $event->arguments(0); if($page->template->name !== 'my_template_name') return; if($page->my_checkbox_name) { $page->name = $sanitizer->pageName($page->title, Sanitizer::translate); } else { $page->name = $sanitizer->pageName("$page->my_extra_field $page->title", Sanitizer::translate); } }); Unfortunately I get this compilation error message: Error: Uncaught Error: Call to a member function pageName() on null Trying to use wire()->$sanitizer leads to another processwire error: Method ProcessWire::pageName does not exist or is not callable in this context Even this simple test script won't work for me: $pages->addHookAfter('saveReady', function(HookEvent $event) { $page = $event->arguments(0); if($page->template->name !== 'my_template_name') return; $page->name = wire()->$sanitizer->pageName("test"); }); I don't see any further reason why/how this would work or not... ?
  4. Hi @bernhard, that's another good hint. Thanks for that! :)
  5. Hi, I'm new to Processwire and it's been quite a while since my last programming experiences with PHP. Currently I'm trying to read through the different site profile versions and stumbled over some code construct in the '_main.php' of the intermediate profile which I've never seen before: foreach($homepage->and($homepage->children) as $item) To me, it looks like 'and()' is used as a method of object '$homepage' in this case but in combination with the 'foreach'-part I don't understand what exactly is happening here and why this is possible. I hope that someone can explain it to me on a basic level :) Thanks in advance Hans
×
×
  • Create New...