Jump to content

Marc H.

Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by Marc H.

  1. Hello folks, I have a strange problem. I have enabled the frontend editing plugin for a website, so that customers are given the ability to customize an assigned page to their liking. However, the problem occurs that by double clicking the elements, to edit the content, those dialogues are opened multiple times. Since I have recently started using the markup regions, I suspect that there is a connection here and certain elements are being outputted twice, whereby the trigger for editing elements is set twice. I'm not sure, what type of informations you'll need to debug this issue, or where to start looking. I'd be grateful if you'd be able to support me, in finding the issue and solving my problem. Thanks in advance. cheers.
  2. I tried it without the redundant fetch of the page, it still throws an error of Null reference. Besides your explanation, which sounds reasonable, the following line does return a valid Page object: $page = $this->pages->get($data->id); Even if the Page isnt saved, it might be, because it isnt an ::saveReady Hook anymore, instead i changed it to ::added Hook. I still need to check the RepeaterMatrix in my Page to not be Null.
  3. Thanks for everyone helping me out here. I found a solution, but if anyone could explain why this works all of a sudden, i would be very grateful. The Code i posted above, all i need to do, was a conditional check if the RepeaterMatrix isnt NULL, then the getNew() call worked: site/ready.php <?php namespace ProcessWire; if(!defined("PROCESSWIRE")) die(); $pages->addHookBefore('Pages::added', function (HookEvent $event){ // Fetch Page Data $data = $event->arguments(0); // Fetch Page Object $page = $this->pages->get($data->id); // Check if the RepeaterMatrix is not NULL if($page->product_matrix != null) { // Save the new RepeaterMatrixPage im going to add, in a Variable $newItem = $page->product_matrix->getNew(); } // Safetycheck if i got anything if($newItem == null) return; // Set RepeaterMatrixPage Type, so the Correct Type of Item gets created and the Data gets saved in the Correct Fields // The Field Types are in the Order of their creation in the RepeaterMatrix Field, and they beginn counting at 1 $newItem->repeater_matrix_type = 2; $newItem->product_properties_title = "Zusätzliche Informationen"; // Save the Item, as it is a Page $newItem->save(); // Add new Children to the RepeaterMatrixPageArray $page->product_matrix->add($newItem); // Save newly created Page again, so the RepeaterMatrix Items are saved in the List. $page->save(); }); I dont know why this works all of a sudden, but im glad it does. kind regards Marc H.
  4. @elabx Thank you for you reply, I figured out that RepeaterMatrixPageArray extends the RepeaterPageArray, so according to this, i should be able to call getNew(). If i can call getNew(), there shouldnt be any problem on adding new Items. My Code: site/ready.php <?php namespace ProcessWire; if(!defined("PROCESSWIRE")) die(); // For Debugging im using the ::saveReady Hook, to not have to create a new page // $pages->addHookBefore('Pages::added', function (HookEvent $event){ $pages->addHookBefore('Pages::saveReady', function (HookEvent $event){ // Fetch Pagedata $data = $event->arguments(0); // Fetch Page Object $page = $this->pages->get($data->id); // Fetch RepeaterMatrix Types $repeaterMatrix = $this->fields->get('product_matrix'); $matrixTypes = $repeaterMatrix->type->getMatrixTypes($repeaterMatrix); // Debuggin Messages $this->message($page->product_matrix->getNew()); // Error-Line }); // Throws following error: // ncaught Error: Call to a member function getNew() on null in site/ready.php:19
  5. I have crawled the Web and the Forum for solutions, and i might have found some other issues im running into. Im trying to add Repeater Matrix Items via a hook in the init.php, it might be an issue, because if i try to call the function RepeaterMatrixPageArray::getNew() it throws an Uncaught Error: Call to a member function getNew() on null It might be, that i have to try to add the Hook at a different place. Thank you for your reply :)
  6. Hi Folks, Unfortunatly my first post will be a asking for help :) I hope anyone can help me with their knowledge. The Repeater Fieldtype does have an api call like $page->repeater_field->getNew() My question is, does something similar exist for the ProFields Module "Repeater Matrix"? For further clarification on what im trying to accomplish: I have a Template with a lot of Fields and one of them is a Repeater Matrix. I use this Matrix to give the Creator the ability to have custom content and can change the order as he likes. But the new Page should already have some Items of this Matrix when the Page gets created. I cant create static fields for those, because the Creator should be able to place Content above it, for example. So my itention was to add specific Items to the Matrix when a Page will be created, via: $pages->addHookAfter('Pages::added', function (HookEvent $event){ // SOME CODE } but i can't figure out how to add Items to a Repeater Matrix. I would be pleased if anyone of you have any advise. If you need some more clarification, i wont hasitate to provide anything you'll need. Thanks in advance, Marc H.
×
×
  • Create New...