Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/26/2023 in all areas

  1. This week in the blog we’ll look at the new WireSitemapXML module, a new WireNumberTools core class, and a new ability for Fieldtype modules to specify useful ready-to-use configurations when creating new fields— https://processwire.com/blog/posts/pw-3.0.213/
    2 points
  2. AdminStyleRock Easily style your ProcessWire backend with two simple settings: Or via RockMigrations: $rm->installModule("AdminStyleRock", [ 'rockprimary' => '#0069B4', 'logo' => '/site/templates/img/kollar.svg', ]); ----------- Background: As of PW 3.0.179 we have a new style in AdminThemeUikit called "rock" style. This thread is here to report issues or ideas for improvement. The goal of the rock style is to make it as easy as possible to adapt your backend to the CI of your client. That's why it uses only ONE single main color and keeps all other design elements in a neutral grey. Download & Docs: https://github.com/baumrock/AdminStyleRock Here is an example screenshot using default uikit colors and a custom base font:
    1 point
  3. 1 point
  4. This error means that you call ->saveField on "null". That means that $pages is "null" in your case. Why is it null? Because it's not defined in your hook. Inside the hook you don't have access to all the PW API variables (like $pages, $sanitizer, etc). There you either need to first make them available (like $pages = $this->wire->pages) or just use the object-syntax: $this->wire->pages->saveField(...) Of course as you mentioned $page->setAndSave(...) does also work (because $page is defined in your hook, so you can work with it). It depends a lot on your use case. You could also add a checkbox to your page and then hook into Pages::saveReady or Pages::saved - there is a small but important difference here: "saveReady" is triggered BEFORE the page is saved, "saved" is triggered AFTER. That means in a saveReady hook you can just set page properties (aka field values) without saving the page (because the page is saved afterwards). In a "saved" hook it's not enough to just change page properties, because the save has already happened so you just change the field values but don't save your changes. // ##### in a saveReady hook $page->foo = "My foo value"; // page save happens here // ##### in a saved hook // page save happened here $page->setAndSave('foo', 'My foo value'); In your case the example with a checkbox could look like this: <?php namespace ProcessWire; // site/ready.php $wire->addHookAfter("Pages::saveReady", function($event) { $page = $event->arguments(0); // only execute on yourtemplate pages if($page->template != 'yourtemplate') return; // checkbox not checked --> dont execute if(!$page->yourcheckbox) return; // checkbox is checked, send email $mail = new WireMail(); // ... $mail->send(); // reset the checkbox $page->yourcheckbox = false; // 0 would also work // page will be saved after this hook // here you could also change other field's values $page->otherfield = 'new value'; });
    1 point
  5. @da², there are probably several standard ready-to-use scripts floating around on this forum and elsewhere and I think there was another module - curious to hear responses from others, I haven't checked recently. Here is a login/register process from the main PW developer Ryan Cramer. It's 5 years old, but I think it should still work and that it was provided as an example that you can adapt and expand to suit your needs. And if you really need a generic out of the box solution, you could always use the Pro module. Here are some of the old threads where I was trying to solve some parts of this, like best practices to secure registration and front-end password reset. Also see this post.
    1 point
  6. 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.
    1 point
×
×
  • Create New...