Jump to content

froot

Members
  • Posts

    715
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by froot

  1. not sure what parent means in this context…
  2. I tried refresh and clear compiled files, doesn't help. Now thinking maybe this problem is related? I posted here yesterday… https://processwire.com/talk/topic/21128-solved-invalid-module-name/?do=findComment&comment=237939 But AFAIK I followed the naming convention alright, that's why I'm kinda stuck.
  3. yes I'm in debug and have tracy. When I uninstall, I can confirm that what ever I log from inside the __uninstall() method doesn't get logged. That is strange. Also, in the module I defined some hooks that get triggered when saving a template. Might that be the culprit? It still makes no sense to me since when I'm uninstalling the module, I'm not on and am not editing a template. public function ready() { $this->addHookAfter("ProcessTemplate::buildEditForm", $this, 'addSimpleSearchCategoryField'); $this->addHookBefore("ProcessTemplate::executeSave", $this, 'saveSimpleSearchCategoryFieldValue'); }
  4. highly unlikely, it was on my local machine.
  5. I wrote this search module: https://github.com/dtjngl/simpleSearch It works OK so far, however I don't know why I cannot uninstall it. When I uninstall it, it keeps reinstalling. Is that issue to be found in the module? Cause I do have locations in my website template files where I initiate this module but that shouldn't matter because it reinstalls (or doesn't uninstall) while still on the modules overview page in admin. Also no mentions of it on ready.php etc. Thanks for help!
  6. I tried that, didn't help. However, once I upgraded my /wire/ folder, no conflicts anymore and I was able to uninstall. So ProcessPageViewStat was never the problem apparently. I could reinstall it actually. Thanks!
  7. I'm having the same issue: ProcessModule: Invalid module name: “.Modules.info” Please use uppercase [A-Z] for first character, lowercase [a-z] for 2nd character, and [a-z A-Z 0-9] for the rest. For example: “Modulesinfo” ProcessModule: Invalid module name: “.Modules.site/modules/” Please use uppercase [A-Z] for first character, lowercase [a-z] for 2nd character, and [a-z A-Z 0-9] for the rest. For example: “Modulessitemodules” ProcessModule: Invalid module name: “.Modules.wire/modules/” Please use uppercase [A-Z] for first character, lowercase [a-z] for 2nd character, and [a-z A-Z 0-9] for the rest. For example: “Moduleswiremodules” ProcessModule: Invalid module name: “.ModulesUninstalled.info” Please use uppercase [A-Z] for first character, lowercase [a-z] for 2nd character, and [a-z A-Z 0-9] for the rest. For example: “ModulesUninstalledinfo” ProcessModule: Invalid module name: “.ModulesVerbose.info” Please use uppercase [A-Z] for first character, lowercase [a-z] for 2nd character, and [a-z A-Z 0-9] for the rest. For example: “ModulesVerboseinfo” ProcessModule: Invalid module name: “.ModulesVersions.info” Please use uppercase [A-Z] for first character, lowercase [a-z] for 2nd character, and [a-z A-Z 0-9] for the rest. For example: “ModulesVersionsinfo However I don't know where exactly this is coming from and am also not sure what is supposed to follow this name scheme. The title? The class name? The .module.php file name? Because all the module classes I see have CamelCase with the first letter Uppercase, so do the module file names and the titles have Title Case and normally allow for spaces too… Thanks for help!
  8. Yes, my bad, It happened because I downgraded to an older version of ProcessWire unintentionally when moving things around. Cheers
  9. I have an issue ProcessModule: Module “ProcessPageViewStat” exists in database but not on the file system. Consider placing the module files in /site/modules/ProcessPageViewStat/ or removing the module from the database. But whether I delete it from the database or add the module folder to the modules folder, in both cases I get: Hmm… Fatal Error: Uncaught Error: Call to a member function render() on null in wire/modules/Process/ProcessModule/ProcessModule.module:995 And can't do anything else anymore… What to do? I'm lost…
  10. OK, trying to answer my own question, Below is my so far working solution, the code I put on ready.php things to note: - it doesn't log and therefor doesn't render error messages - I tried to put that in a separate module, but the problem seems to be, that both hooks would call methods from two different classes, so for the first hook I would need to extend the Wire class and for the second the Process class. Two modules for this simple functionality seems a bit overkill and then it can only do this… - Maybe a better idea would be to extend the Diagnostics-module directly? Which ever one makes sense. (ProcessDiagnostics, DiagnoseModules, …) - in order to make this code work, you'd still need to make the method GetDiagnostics hookable, so add ___ to GetDiagnostics in DiagnoseModules (I know, it's a hack) // ready.php $this->addHookAfter('DiagnoseModules::GetDiagnostics', function ($event) { wire('log')->delete('diagnostics'); $results = $event->return; // Loop through results and extract the entries that are warnings and failures and log them foreach ($results as $result) { if ($result['status'] != '') { wire('log')->save('diagnostics', $result['status'] . ': ' . $result['title'] . ' - ' . $result['value']); } } // Return the modified results $event->return = $results; }); function formatDiagnosticMessage($line) { $lineParts = explode(':', $line); $severity = $lineParts[0]; $message = $lineParts[1]; $formattedMessage[0] = $severity; $formattedMessage[1] = $message; return $formattedMessage; } $this->addHookBefore('PageRender::renderPage', function(HookEvent $event) { // Get the object the event occurred on, if needed $PageRender = $event->object; // Get values of arguments sent to hook (and optionally modify them) $event = $event->arguments(0); $page = $event->page; $info = ' - check Diagnostics-module for further investigation.'; if ($page->template != 'admin') return; $ProcessDiagnostics = wire('modules')->get('ProcessDiagnostics'); if (!file_exists('site/assets/logs/diagnostics.txt')) { $this->message('No warnings or errors found' . $info); return; } $diagnosticsFile = fopen('site/assets/logs/diagnostics.txt', 'r'); $diagnosticsLines = []; while (($line = fgets($diagnosticsFile)) !== false) { $diagnosticsLines[] = $line; } fclose($diagnosticsFile); foreach ($diagnosticsLines as $line) { $parts = explode(' ', $line); $formattedMessage = formatDiagnosticMessage($parts[3]); if ($formattedMessage[0] == 'Warning') { $this->warning($formattedMessage[0] . ': ' . $formattedMessage[1] . $info); } if ($formattedMessage[0] == 'Failure') { $this->error($formattedMessage[0] . ': ' . $formattedMessage[1] . $info); } } $event->arguments(0, $event); });
  11. I want to hook into the module and log the warnings and failures, is that doable? This is what I tried with no luck: //ready.php $this->addHookAfter('ProcessDiagnostics::___collectDiagnostics', function($event) { // Get the instance of the ProcessDiagnostics module $module = $event->object; // Get the title, value, status, and notes from the hook event $title = $event->argument('title'); $value = $event->argument('value'); $status = $event->argument('status'); $notes = $event->argument('notes'); // Log the information to the console wire('log')->save('diagnostics', $title); wire('log')->save('diagnostics', $value); wire('log')->save('diagnostics', $status); wire('log')->save('diagnostics', $notes); });
  12. is there a way to select pages by some (usually the current, or user?)-language specific value only? I'm aware that there's a method that I can use, but I'd prefer to use a selector, if possible. so instead of $results = new WireArray; $query = "banana"; $indexed = $pages->find("template=some_template"); foreach ($indexed as $p) { if ($p->getLanguageValue("english", "title|headline[preview|body") == $query { $results->add($p); } } I'd like to something like: $query = "banana"; $results = $pages->find("template=some_template, title|headline|preview|body=LanguageValue("english", $query)"); or $results = $pages->find("template=some_template, title_1021|headline_1021|preview_1021|body_1021=$query"); thanks for help!
  13. how would make a custom page class for the template basic-page ? basic-pagePage? Basic-pagePage? Basic-PagePage?
  14. can I generate an InputfieldAsmSelect to select pages from the page-tree?
  15. I have a weird issue I have a couple of PageArray objects of which, when I do a print_r, the children are all not at the [items] but at the [items_removed] key/position, seemingly at random. In the page tree everything looks normal (not hidden or unpublished or in the trash) and everything looks just like all the other PageArray obects with no issue. Any ideas what that could be?
  16. I know I'm sort of preaching to the choir here, but it's a shame you cannot add images in SF. I think what many devs, me included ,want to use this module for is for global settings which includes things like logo(s). It just makes so much more sense to have these things defined in a separate page rather than by adding fields to the home template but maybe I'm just being too neurotic. Please forgive me if this is a dumb question, but since I have to create a page under the admin page tree to get SF to work, why can't I add images to this very site's /assets/files/ folder? But I guess the answer does something like because the fields I create on the required php or json file don't really exist in the system and are create at runtime?
  17. I tried that, FYI I see PHP Warning: Undefined array key "footer_imprint__1021" in .../modules/SettingsFactory/ProcessSettingsFactory.module:151
  18. yes of course, I remember now Thanks!
  19. has something changed in this module? Because I cannot seem to find the place where you enter the path to the json or php file with the settings array. I'm on ProcessWire 3.0.207
  20. I'm having some difficulties understanding how this works and getting started. So I installed Vue JS inside a folder in /site/templates/scripts/vue/ created a vue app inside of that folder and did vue add vuetify I followed the instructions in the official vuetify guide and did a npm run build Anyways, I miss the part where I include the vuetify .css and .js files in the <head> or <body> tag respectively. Which files do I need to include?
  21. thanks @LMD for your feedback, yes I assumed there must be a lot of overhead in my code the way it is now. I will update it soon to use SQL commands and update it probably again once meta is accessible via selectors.
  22. thanks @bernhard, yes I noticed that later on. I managed to get the module to serve my needs, it's here: https://github.com/dtjngl/MenuAllocator I (re)watched your hook-tutorial, it's interesting but I doubt it can help me in this very use-case since I do not really populate fields on the page and the fields in question are rendered at runtime (by a another hook), so I had a hard time saving the values to the page (luckily there's ->meta). I'm not sure if this is the best approach but it works. @everyone, please give it a try, I'd love to get feedback.
  23. public function ready() { $this->addHookAfter('ProcessPageEdit::buildFormContent', $this, 'addCustomFieldToPageEditForm'); // ... } public function addCustomFieldToPageEditForm(HookEvent $event) { $page = $event->arguments('page'); // null // ... } ;( EDIT: $id = $this->input->get('id'); // frontend page object id $page = wire('pages')->get($id); // frontend page object ?
  24. doesn't work ? should be so easy though, right? class MenuAllocator extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Menu Allocator', 'version' => 1, 'summary' => 'A module to allocate menus to pages.', 'autoload' => 'template=admin', ); } public function ready() { // Add a hook to build the page edit form content $this->addHookAfter('ProcessPageEdit::buildFormContent', $this, 'addCustomFieldToPageEditForm'); // Add a hook to process the form input when the page is saved $this->addHookBefore('Pages::saveReady', $this, 'saveCustomField'); } public function init() { bd($this->meta); } public function addCustomFieldToPageEditForm(HookEvent $event) { $form = $event->return; // Check if this is a frontend page (you can define your criteria here) if (strpos($this->input->url, '/admin/') !== false) { // Create the custom field as an InputfieldText $field = $this->modules->get('InputfieldText'); $field->name = 'custom_text_field'; // Use a different name for rendering $field->label = 'Custom Field for Display'; // Different label for rendering $field->description = 'Enter a custom value for this page (display only).'; // Add the field to the page edit form $form->add($field); } } public function saveCustomField(HookEvent $event) { // Get the page object from ProcessWire's API $page = wire('page'); // Check if the page object exists if ($page instanceof Page) { // Get the custom_text_field value from the form input $fieldValue = $this->input->post->custom_text_field; // Use the correct field name // Set the custom field value to the page's meta data $page->meta->set('custom_text_field', $fieldValue); // Use the correct field name for meta data } } }
×
×
  • Create New...