-
Posts
726 -
Joined
-
Last visited
-
Days Won
3
Everything posted by froot
-
The module still needs quite some improvement. One issue that needs attendance is the following. I build a selector and select a page array from the database. $selector = $this->createSelector($this->q, $category); bd($selector); $unfilteredMatches = $this->pages("$selector, start=0, limit=99999"); As discussed in this thread it's (so far) impossible to select pages based on language specific field values. So the query looks through the field values in all languages for the search term. Since this is not what I want, instead I want the query to only match the fields values of the current user language, I do another loop and within that loop, with the method buildSnippets() I create the snippets for the markup. If this returns null (this is now language specific) I sort out the page entirely. $strippedFieldValue = strip_tags($fieldValue); // Find the position of the search term in the field value $position = stripos($strippedFieldValue, $searchTerm); // If the search term is not found, return an empty string if ($position === false) { return false; } So basically I'm selecting once via selector and then narrow it down with a loop. That works for a one-term search query or an exact phrase, but it makes sense that It won't and doesn't work when the search operand is on the fancier side as listed here: https://processwire.com/docs/selectors/operators/#contains What would you suggest? Is my approach so far sensible? Should I hard-code a different loop condition for each of the fancy search operands? I want to give the module-user (not enduser but admin user) the option to adjust the search operand in the module's settings. Thanks for help!
-
OK I found the culprit. I was initiating the module on a custom page class just to make use of one method., not a good idea.. Now that I found a work-around it works fine and I can uninstall with no issues.
-
I actually found this in the modules.txt log file: 2023-12-21 11:36:09 admin https://mysite.ddev.site/admin/module/edit?name=SimpleSearch&collapse_info=1 Uninstalled module 'SimpleSearch' 2023-12-21 11:36:10 admin https://mysite.ddev.site/favicon.ico Installed module 'SimpleSearch' Super strange! I removed the favicon.ico links in the head tag, removed the favicon icons, cleared cache, refreshed modules, cleared compiled files, issue remains Will try this now: EDIT: I just tried this and Tracy doesn't bd-log anything from inside the install() method nor the uninstall() method, I mean not even this gets logged: bd('install'); So strange!
-
OK then I think the right question to ask would be: why am I seeing this?
-
I don't know if this is related but I'm seeing a lot modules under the "Missing" tab which are actually not missing. I did of course refresh and check for new modules and also clear compiled files. The modules do appear under "Missing" and under the regular modules tab as if they were just fine. At least one of them, "System Notifications" is even a core-module and I think TineMCE as well, see screenshot.
-
not sure what parent means in this context…
-
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.
-
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'); }
-
highly unlikely, it was on my local machine.
-
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!
-
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!
-
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!
-
Yes, my bad, It happened because I downgraded to an older version of ProcessWire unintentionally when moving things around. Cheers
-
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…
-
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); });
-
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); });
-
yes, exactly
-
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!
-
Custom Classes for Page objects - The Discussion
froot replied to szabesz's topic in API & Templates
how would make a custom page class for the template basic-page ? basic-pagePage? Basic-pagePage? Basic-PagePage? -
can I generate an InputfieldAsmSelect to select pages from the page-tree?
-
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?
-
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?
-
I tried that, FYI I see PHP Warning: Undefined array key "footer_imprint__1021" in .../modules/SettingsFactory/ProcessSettingsFactory.module:151
-
yes of course, I remember now Thanks!
-
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