Jump to content

JayGee

Members
  • Posts

    257
  • Joined

  • Last visited

Everything posted by JayGee

  1. SOLVED - but I'll leave this here for anyone else to reference as I struggled to find examples. Long story short, I think I was massively overthinking it - with a bit of help from Chat GPT (!! Chat GPT know ProcessWire now - who knew!) I've got this: ..... } elseif($field->type == 'FieldtypeRepeaterMatrix') { //HANDLE REPEATERS HERE $repeaterItems = $page->$field; foreach ($repeaterItems as $item) { // Iterate over each field in the Repeater Matrix item foreach ($item->fields as $subField) { $subFieldName = $subField->name; $subFieldValue = $item->get($subFieldName); // Perform your modification here if the subfield is a string type if (is_string($subFieldValue)) { $modifiedValue = $this->replace_merge_tags($subFieldValue, $tags, $defaultTags); // Save the modified content back to the item $item->set($subFieldName, $modifiedValue); } } } }
  2. I've got some code that is carrying out a basic find-and-replace operation on some page output. I'm hooking into the page render: $this->addHookBefore('Page::render', $this, 'renderOutput'); Looping through the fields and modifying page output accordingly which is all working fine. The problem is I cannot figure out what approach I should be using for doing the same on repeater or repeater matrix fields in the page output. As far as I can tell Page::render hook doesn't fire for the repeater pages so I presume I need to loop through the matrix item sub fields at output. Does anyone have any guidance/examples - I can only find examples for hooking repeaters on CMS side rather than frontend output.
  3. Thanks @BitPoet - exactly what I was looking for. ?
  4. DW - Found it ?‍♂️ Had to add some logic to detect if we're already on the 404 page as my array check was broken because the data isn't present on the 404 (created a loop). if (array_key_exists($this->input->urlSegment1,$allVariantData)) I'm now doing if($page->id != 27) { //Wrap in condition to ensure this logic doesn't affect 404 pages is this the best way to detect a 404 page? Does the 404 ID ever change, or is this solid enough to rely on?
  5. I have an autoload module with the follow (abridged) code. The problem is that I cannot seem to throw the 404 error below. There's no page output prior to this point, so I can't see why this isn't working. Hoping someone else can! Hook via init() <?php public function init() { $this->addHookBefore('Page::render', $this, 'renderOutput'); } my function: <?php public function renderOutput($event) { $variant = 'defaults'; if ($this->input->urlSegment1) { if (array_key_exists($this->input->urlSegment1,$allVariantData)) { $variant = $this->input->urlSegment1; } else { throw new Wire404Exception(); //throw 404 to prevent made up variants resolving dynamic default data for 'pages' that don't exist } } } I've taken out the code not relevant to the issue but can confirm all the other logic and that around the url segments is all running as expected. I just get an exception when I try to call the 404 exception!
  6. It would be cool to try and get something up and running. I think there's a growing awareness of PW and we pick up a few but ever increasing number of organic enquiries from people who have PW sites built for them by other people so it only seems natural they would check the PW website to find devs.
  7. On second thoughts - hasparent is a page selector isn't it rather than a template selector? EDIT: Can confirm this works perfectly for my scenario - thanks for your help @wbmnfktr and @Robin S: $templates = $this->templates->find("flags=0"); Now I know of the existence of the template flag system this is really handy. For reference for anyone readying this in the future, checking the database I can see the standard templates all have flag 0 as implemented above. The admin repeater templates are all flag 8.
  8. Thanks both, this all makes sense - I knew there would be a way I was overlooking! I think in all likelihood I'll use a combination of the 2 suggested selectors as there's no reason for me to touch anything in the admin folder: $non_system_templates = $templates->find("flags=0,!hasParent=2"); I need to make sure I also exclude repeater templates. The reason this issue came up is because I'm adding a repeater field, and it got added to the repeater templates which caused an infinite loop when adding a repeater item! ?‍♂️
  9. This feels like it should be simple but can't see it in the API docs. I want to loop through all a site's templates and add some fields via a module, but I don't want to touch admin templates. What's the best way to filter them? Is there a selector for $templates->find() like admin=false or similar?
  10. Are you 100% certain it is Cloudflare causing this issue. It took me many years of using ProcessWire to realise that it was me causing logouts by opening the browser dev tools device emulator for testing during site development. This happens because it sends a new user agent header and triggers a new session in the browser, therefore logging you out of the old session. You can see this happening in the PW logs - it records it as 'session invalidated' or similar.
  11. Just an idea - not particularly thought through so may not work!... Because you can so easily add another URL to ProcessWire sites via the config, I wonder if you could use a separate URL or subdomain for editing access that doesn't go through CF. You could restrict access for editing by IP so other people can't use that domain.
  12. We use various versions of this module on a lot of sites and I also haven't come across this. Do you have the actual error message?
  13. Have you ever listened to the podcast Darknet Diaries - this is the exact vibe I always get about how these hackers are operating. Begrudging admiration for the ideas they come up with. Given that most email css is inlined, does this require the machine or platform of the mailbox doing the forwarding to be compromised? Otherwise how are they modifying the CSS without the forwarder's intervention? I guess a dodgy browser extension could also do this ? I.e. target the CSS of known mailboxes e.g. when you visit gmail or outlook. EDIT: After reading the article I realise I misunderstood the concept. So they're not modifying existing emails, they're sending and email with this method build in as hidden payload. I guess the lesson being to ensure trust of the original message.
  14. Hi @ryan does this module handle frontend edits?
  15. I think you may have made the same mistake I did in that original post... $collections->sync_queue("product={$product}, limit=1"); // this not work in hook should be: $collections->sync_queue->find("product={$product}, limit=1"); // this not work in hook (find missing in the top one).
  16. @ryan - Have just implemented this in a production project to fill a very specific need and it has worked a treat. Thank you! ? ? ? ?
  17. JayGee

    Hanna Code

    It was on latest stable 3.0.229. Updating to latest dev 3.0.231 seem to resolve it. For clarity I'm doing to work updating a fairly old site - so I can't 100% say it isn't something in the legacy code or a Handover from the older PW version I updated from.
  18. 12hrs later I can confirm everything is running smoothly so far! Will report back on this thread if any issues. But great to know we can use MarkupRegions retrospectively on older sites like this.
  19. JayGee

    Hanna Code

    Are people still actively using Hanna Code? I'm trying to do an install of it on a site for the first time in a while. Hitting a problem getting the module to install. The text formatter will install, but not the Hanna Code module meaning I don't get the editor (even with the config added or site in debug ?).
  20. Found answers here: https://github.com/processwire/processwire-issues/issues/1307 I think this happened to me today as I ran an update on an older install that hadn't been touched for a while rather than it being an issue with current PW.
  21. Is there any update on this? Also seeing this error in 3.0.299 and it's causing some issues installing modules.
  22. Just checking something I've not done before... I've upgraded an old site to PW latest stable and I want to add some new features using MarkupRegions but only on one template. I've enabled MarkupRegions in config as usual but skipped the append. I've then appended my _main.php file in the template settings instead, so as to target it only to one template type in the site. $config->useMarkupRegions = true; //$config->appendTemplateFile = '_main.php'; <--- added this manually to one template in the UI instead of via config.php Is this ok? It seems to be working, but just checking I'm not introducing any unforeseen pain? I've only ever used MarkupRegions as an all-of-nothing type thing before!
  23. Yes this is what I was doing... but turns out I had a typo and it was loading my 404 page in the panel I think. This is why I was getting the nav bar showing ?. The panels now work exactly as expected (and as you describe) to load my module functionality! ?
  24. Sorry to be clearer on my question - what I'm wondering is whether there's a core method for injecting dynamic content to PW panels and modals in the dashboard rather than writing new logic. I know you can load a page into the panels, however that then seems to reload the whole dashboard interface including nav etc inside the frame.
  25. Hi all, I'm looking for some examples/guidance/tutorials on how to populate a PW panel from a module. I know you can open a UIKit panel with a .pw-panel css class and that you can populate it with a custom admin page. But I'm wondering the best approach to populating with dynamic module-specific content, e.g. a form? TIA J
×
×
  • Create New...