Jump to content

saleo

Members
  • Posts

    9
  • Joined

  • Last visited

Everything posted by saleo

  1. Hello. I'm trying to track the changes of a textarea field. The field has a TinyMce inputifeld configured and Markup/Html as content type. To track the changes I use this hook in the init.php: wire()->addHookBefore('Pages::saveReady', function($event) { $page = $event->arguments(0); if($page->template->name === 'wiki-page'){ if($page->isChanged('body')){ bd($page->getChanges()); //using Tracy here } } }); The issue is that the isChanged method returns ['body'] even if the body field has not changed, but only when some type of markup is present. For example, if I put some simple formatted text and I save the page, the changes are tracked correctly. But if I put a <table> or a <ol> in the body, when I save the page the isChanged method returns always ['body'], even if I have not changed anything. Am I doing something wrong with the hook? Maybe the saveReady is not the correct place to track changes? Or is this a Processwire issue? I'm using Processwire 3.0.227, the only extra plugins installed are ProcessDatabaseBackups and TracyDebugger, and I'm using php 8.2.4 in a Mamp Pro installation on MacOs. Thank you! Leo
  2. Hello. I don't know if this is a bug or if I'm using a bad practice. I'm testing out latest pw 3.0.167. I'm used to write this whenever I need to create a new Page from api $p = new Page(); $p->template = 'upload'; $p->title = 'my new page'; $p->parent = 1019; $p->save(); The following code is quite similar, yet when used inside a custom page class is generating a nasty issue. $upload = new Page(); $upload->template = 'upload'; $upload->parent = wire()->pages->get("template=uploads"); $upload->title = time() . '-' . $email; $upload->nome = $nome; $upload->cognome = $cognome; $upload->email = $email; $upload->addStatus(Page::statusUnpublished); $upload->save(); After execution, the admin stops working with this exception Umm… Fatal Error: Uncaught Error: Call to a member function getPageClass() on string in wire/core/PagesLoader.php:945 #0 wire/core/PagesLoader.php (421): PagesLoader->getById(Array, NULL) #1 wire/core/Pages.php (255): PagesLoader->find('parent_id=1019,...', Array) #2 wire/core/Wire.php (400): Pages->___find('parent_id=1019,...', Array) #3 wire/core/WireHooks.php (823): Wire->_callMethod('___find', Array) #4 wire/core/Wire.php (465): WireHooks->runHooks(Object(Pages), 'find', Array) #5 wire/core/Page.php (4577): Wire->__call('find', Array) #6 wire/core/PageTraversal.php (130): Page- (line 945 of wire/core/PagesLoader.php) This error message was shown because: you are logged in as a Superuser. Error has been logged. Looking in the database, I notice that the new created page has no template assigned If I remove that row from the db, the admin resumes working nicely. Now if I change this $upload->template = 'upload'; to this $upload->template = wire()->templates->get('upload'); everything goes as expected. Any ideas? Thank you Leo
  3. You're right, but I only used the echo code to make the problem more obvious. In fact, initially I noticed the problem when I saw that a call to Aws was executed twice. So I'm wondering if it is possible to insert any code in the opening section of the template file, without it being executed twice?
  4. Hello, I'm using the Markup regions template strategy https://processwire.com/docs/front-end/output/markup-regions/ I noticed that any code at the beginning of the source file is executed twice. For example <?php namespace ProcessWire; echo "TEST<br>" ?> <main id="main" pw-append> </main> will output the word "TEST" twice. Is this normal behavior? Maybe @ryan can shed some light? Thank you Leo
  5. Ok, I acted too fast, sorry. Solution found in this topic. I have to use the role id, not the role name. So, for example, "roles=1040" instead of "roles=client".
  6. Hello. Maybe this is a known limitation, but after a bit of research I couldn't find any information about this. I created two roles, "client" and "agent". I have added some custom fields to the user template, and I want to show some of them only if the user (the user that is edited, not the logged in user) has the "client" role assigned. So, in the user template I set the "show this field only if" field to "roles=client", for those fields. Now, when I assign the role to the user, the fields are showing correctly (and they hide when I remove the role). But when I set a value and save the page, the fields are not saving any data. But if I change the condition to "roles!=agent" (or I totally remove it), the fields behave as usual, saving the data correctly. Is this a known limitation, or am I doing something wrong? Thank you!
×
×
  • Create New...