Jump to content

Studio Lambelet

  • Posts

  • Joined

  • Last visited

Profile Information

  • Location

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Studio Lambelet's Achievements

Jr. Member

Jr. Member (3/6)



  1. Hi @siaweb, Do visitors have access to the pages of the "assortment_name.home_menu=1" selector? Did you try with include=all in the find()? Looks like an issue of access control: https://processwire.com/docs/selectors/#access_control I personally think it would be better to resolve the access of the pages instead of using include=all, but you do you 🙂
  2. Hey @adrian, thanks for the great module! I have an issue with .webp files, they are not renamed at all on page save. JPG are renamed without any problem. What could I do to find a solution to this ? Using PW v3.0.200, PHP 8.1, no errors in Tracy.
  3. Hi Inxentas, You need to get InputfieldCKEditor instead of InputfieldTextarea. $field = wire('modules')->get('InputfieldCKEditor'); $field->columnWidth = 100; $field->attr("id+name", "source_text"); $field->label = "Source Text"; $field->icon = "fa-align-left"; $field->value = "<h1>Yeah HTML!</h1>";
  4. Regarding the dummy title, I did not test this code, but based on @bernhard reply, I think this should work: // ... Rest of the code before $p = new Page(); $p->parent = $parent; $p->template = 'your-child-template'; $p->title = 'your dummy title'; $p->save(); $event->session->redirect($p->editUrl()); // ... Rest of the code after As for the parent page, in the admin Processwire use a GET input to pass the page id ("?parent_id=X). // Hook is in /site/ready.php (or /site/templates/admin.php) $this->addHookAfter('ProcessPageAdd::buildForm', function ($event) { // Retrieve GET input "parent_id" $parentIdInput = $this->wire('input')->get['parent_id']; // Sanitize GET input $parentId = $this->wire('sanitizer')->int($parentIdInput); // Get page $parentPage = $this->wire('pages')->get($parentId); if ($parentPage->id) { // Retrieve the form $form = $event->return; // Create an inputfield markup to display some html. $field = $this->wire()->modules->get('InputfieldMarkup'); $field->name = 'messageToUser'; $field->value = "<p>The parent page title is {$parentPage->title}.</p>"; // Use "$form->add()" if you want your message at the end of the form (after button) $form->prepend($field); // Populate back argument $event->return = $form; } });
  5. Hi Florian, I'm not sure I completely understand what you want to achieve, seems like there are different ways to achieve what you want. Could you describe it in steps? As for displaying a message on the new page form, you can hook to ProcessPageAdd::buildForm. Here is an example. // Hook is in /site/ready.php (or /site/templates/admin.php) $this->addHookAfter('ProcessPageAdd::buildForm', function ($event) { // Retrieve the form $form = $event->return; // Create an inputfield markup to display some html. $field = $this->wire()->modules->get('InputfieldMarkup'); $field->name = 'messageToUser'; $field->value = "<p>Your message or anything else goes here!</p>"; // Use "$form->add()" if you want your message at the end of the form (after button) $form->prepend($field); // Populate back argument $event->return = $form; });
  6. I'm working on a page builder module that extends FieldtypeMulti, with the same way of storing data as FieldtypePagetable (field value is a WireArray). I'm using ProcessWire 3.0.200 / PHP 8.1.6. Everything is working fine on all the pages I use this module except on the homepage (id = 1). If I try to save a new value on the homepage, the system throws the following error: Here is the code used for saving the field value: /** * Add a page to a PageBuilder * * @param int $parentForBuilder id of page that contains the builder * @param string $builderName the name of the PageBuilder field * @param int $newPageId the newly created page id * @param string $position position to add new bloc, can be: first, before, after, last * @param int $prevPageId either 0 or ID of page the new bloc should be before/after * * @return void * */ protected function addBlocToBuilder(int $parentForBuilder, string $builderName, int $newPageId, string $position, int $prevPageId) { $parentPage = $this->wire('pages')->get($parentForBuilder); if (!$parentPage->get($builderName)) { $this->exitError(400, __('Could not get builder.')); } // FYI, $builder is a WireArray $builder = $parentPage->get($builderName); if (!$builder) { $this->exitError(400, __('Could not update WireArray.')); } if ($position === 'first') { $builder->prepend($newPageId); } else if ($position === 'before') { $builder->insertBefore($newPageId, $prevPageId); } else if ($position === 'after') { $builder->insertAfter($newPageId, $prevPageId); } else { $builder->add($newPageId); } $saveState = $parentPage->setAndSave($builderName, $builder); return $saveState; } According to the documentation setAndSave "does not need output formatting to be turned off first". So I would not except this error. I also tried saving with the following code instead of setAndSave(), without success: $of = $parentPage->of(); $parentPage->of(false); $parentPage->set($builderName, $builder); $parentPage->save($builderName); $parentPage->of($of); I find it particularly weird that this bug only occurs on the homepage. One more thing that doesn't make sense to me: if I call a bar dump from Tracy Debugger before saving - e.g. bd(wire('user'); saving will success... I would be really happy if someone could give me some advice, I spent really too much time on this bug. Thanks in advance!
  7. Thanks elabx! I read the documentation a bit too quickly 😅 For anyone having the same misunderstanding in the future, I solved it by using PHP array_search().
  8. I'm working on a module that extends FieldtypeMulti, with the same way of storing data as FieldtypePagetable (field value is a WireArray). I used without any issues WireArray->add(), WireArray->prepend() or WireArray->insertAfter() but WireArray->remove() doesn't seem to work. Here is a minimal test case (tested in module init(), PW version 3.0.200) $array = wire(new WireArray); $array->add('Foo'); $array->add('Bar'); $array->add('Baz'); bd($array); /** * ProcessWire\WireArray * count: 3 * items: array * 0 => 'Foo' * 1 => 'Bar' * 2 => 'Baz' */ $array->remove('Foo'); // $newArray = $array->remove('Foo'); does the same... bd($array); /** * ProcessWire\WireArray * count: 3 * items: array * 0 => 'Foo' * 1 => 'Bar' * 2 => 'Baz' */ I would expect the WireArray to remove the element and update the count. But alas, it's not doing anything. Does anyone with an idea of what I don't understand here? Thanks!
  9. Hi @Sebi ! Thanks a lot for your long reply! Regarding the 404s, I totally understand. I remember now that I had used the same kind of hook for a module a while ago. But would it make sense to remove the "404" part of the url in the log? It's really a cosmetic thing though, not fundamental. Thank you very much for testing whether Session Login Throttle works. I am reassured! I think it's my implementation that is not quite right yet. I'll keep testing and ask a new question if I really can't find a solution. Thanks again for your help!
  10. Hi @Sebi! Thanks a lot for your module, really great, having fun with it for a little side project! After some testing, I have a two questions: First thing (not really essential and I may have made a mistake in the way I set things up), but the access-log shows all urls as starting with "/404/". JS side requests are working fine (http 200). The rest of the url shown in access-log is fine. A little more significant, the function that handles authentication does not seem to respect the Session Login Throttle settings (I'm using double JWT). I'm a bit paranoid perhaps, but this seems to present a risk of brute-force attack. Is this the case, or is my implementation wrong? Thanks a lot!
  11. Thanks a lot for your replies! @Zeka I was hoping it was not too late to hook during module's init method, alas... And I can't really add the hooks to initBefore.php or boot.php as the idea is to release the module publicly (and that it works without the end user having to add a hook himself). @Jan Romero Super interesting this new preload feature! I'm just wondering if it's not a bit of a loss to create a module that requires the Dev branch. I've currently developed it to work on the Master branch. Anyway, this functionality is not super fundamental to the module. I will for the moment, as you recommend, get the time during the init of the module. Thanks again!
  12. Hi! Sorry to bump this, but I'm still trying to wrap my head around this. I re-read $wire->init() reference. It states "Hookable init for anyone that wants to hook immediately before any autoload modules initialized or after all modules initialized". I would expect that $this->addHookAfter("ProcessWire::init", $this, 'addMark'); to works, as the module is autoloaded. Why is this hook not working ? Would there be a workaround? I'm looking to hook as soon as possible during Processwire execution.
  13. Hello, I'm working on a module wich will do some performance monitoring. I would like to be able to record time during the main hooks of Processwire. But unfortunately, the Processwire::init hook never execute, either with addHookBefore or addHookAfter. Here is a minimal test case, output is in a TracyDebugger bar dump. <?php namespace ProcessWire; /** * Minimal test case to hook to Proceswire::init * Output is a TracyDebugger bardump * */ class HookInit extends WireData implements Module { /** * Array to store all server-timing marks * * @var array */ public $marksArray; public static function getModuleInfo(): array { return [ 'title' => __('Hook Init'), 'singular' => true, 'autoload' => true, 'requires' => [ 'ProcessWire>=3.0.165', 'PHP>=7.1.0', ], ]; } public function __construct() { $this->marksArray = array(); } public function init() { // DOESN'T WORKS $this->addHookBefore("ProcessWire::init", $this, 'addMark'); // DOESN'T WORKS $this->addHookAfter("ProcessWire::init", $this, 'addMark'); // WORKS $this->addHookBefore("ProcessWire::ready", $this, 'addMark'); // WORKS $this->addHookAfter("Page::render", $this, 'addMark', array("priority" => 199)); // Display in TracyDebugger bar dump $this->addHookAfter("Page::render", $this, 'displayMarks', array("priority" => 200)); } /** * Add a server-timing mark to the array * * @param HookEvent $event */ public function addMark($event) { $this->marksArray[$event->id] = microtime(true); } /** * Output $this->marksArray via TracyDebugger * * @param HookEvent $event */ public function displayMarks($event) { bd($this->marksArray); } } ?> I am definitely doing something wrong (still learning...). Any help will be greatly appreciated! Thanks!
  14. Okay, I found the issue! I should have mentioned that I work on a multi-lingual site. Here's the problem (and the resolution): I removed the value "inherit from default language" for the field Title (because the inheritance didn't seem to me to be the right approach for the translation of this field). This had the effect of making the title empty. If I reactivate the inheritance, the problem is solved. Thanks a lot for your help, really like PW community!
  15. Hi Edison, thanks for your reply! It's sadly not a css issue. I checked and there is no text inside the link. Attached is a screenshot of the Setup dropdown menu (uikit theme), as you can see there is no text in the markup. I didn't change or add js. Before the bug occured I was changing the main list of pages (via ProcessPageListRender::getPageLabel in site/ready.php), but if I comment out the code the bug still occurs.
  • Create New...