Leaderboard
Popular Content
Showing content with the highest reputation on 02/27/2023 in all areas
-
I've had a look and found the issue: ready.php is never triggered on frontend editing. You can attach your hook in /site/init.php for example and then it should work. The hooks are the same as for regular page saves: You can hook into Pages::saveReady or Pages::saved for example.2 points
-
Time to revive this 8 year old thread ? I'm using vscodium as editor and recently for code formatting I moved from the excellent https://intelephense.com/ extension to an extension that uses https://github.com/PHP-CS-Fixer/PHP-CS-Fixer which is based on https://github.com/squizlabs/PHP_CodeSniffer. This allows custom style definitions (rulesets) https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file PW coding style guide says: Has anybody ever gone through the trouble of creating a custom PW ruleset.xml? Just asking before I start spending my time on that. Other CMSs/Frameworks do have their ruleset files. See https://github.com/WordPress/WordPress-Coding-Standards https://www.drupal.org/docs/contributed-modules/code-review-module/installing-coder-sniffer https://github.com/fossbarrow/laravel-phpcs Would be great if we had one for ProcessWire, too. Maybe @ryan already uses one and can share it? If not, we could start a community effort to produce such ruleset. It would help tremendously for PRs to the PW core or for module development.2 points
-
I've been working further on the module concept and found a (mostly reliable) way to react on all error types in PW. Just wanted to share my findings before a release. Looking through PW core, I found that nowhere PW registers custom error or exception handlers. So I decided to use set_error_handler() for warnings/notices and set_exception_handler() for exceptions. To also cover fatal errors, I hook into WireShutdown::fatalError instead of registering my own shutdown function. Gladly Ryan provides that hook ? So the basis for my operations looks like this in the module's init(): $this->originalErrorHandler = set_error_handler(array($this, 'errorHandler'), E_NOTICE|E_USER_NOTICE|E_WARNING|E_USER_WARNING); $this->originalExceptionHandler = set_exception_handler(array($this, 'exceptionHandler')); $this->wire->addHookAfter('WireShutdown::fatalError', $this, 'fatalHandler'); Note, how I save the original error and exception handlers, so I can set them back once I've finished my operations so that my module doesn't interfere with other modules that use their own handlers (like TracyDebugger). For now I'm only doing the send email based on error type part. The https://rollbar.com/ part will most likely go into a separate module. I still need to test some on a production site until there will be an alpha/beta release. Related question: does anybody know how to deliberately cause an E_NOTICE error, other than using trigger_error('My error', E_USER_NOTICE) in PHP > 8? I couldn't find or think of a real world example. Before PHP 8 we could use "echo $undeclaredVariable". But since 8 those notices are converted to warnings.2 points
-
@adrian, thanks for looking into this request but after some more investigation I don't think there will be a good way for PageRenameOptions to deal with the ProcessPageClone issue. It's something that would need to be addressed within ProcessPageClone. It works out the copy number - (copy 2), (copy 3), etc - by looking at the page name to check for an existing number suffix. So it needs to name the first clone with a "1" suffix and yet it wants to title that first clone without the "1". If we change PageRenameOptions to set the clone name from the title then there's no number suffix on the first clone and so it messes up the calculation for subsequent clones. I don't think there will be changes to ProcessPageClone any time soon, and in fact the whole problem would largely be avoided if my request from 2018 was actioned. So instead I'm going to solve this with a couple of extra hooks: // Make ProcessPageClone always use "Copy Page" form // https://github.com/processwire/processwire-requests/issues/186 $wire->addHookAfter('ProcessPageListActions::getExtraActions', function(HookEvent $event) { $page = $event->arguments(0); $actions = $event->return; if(empty($actions['copy'])) return; $config = $event->wire()->config; $actions['copy']['url'] = "{$config->urls->admin}page/clone/?id={$page->id}"; $event->return = $actions; }, ['priority' => 200]); // Set "Copy Page" name field to match title field $wire->addHookAfter('ProcessPageClone::buildForm', function(HookEvent $event) { /** @var InputfieldForm $form */ $form = $event->return; $title_field = $form->getChildByName('clone_page_title'); $name_field = $form->getChildByName('clone_page_name'); if($title_field && $name_field) { $name_field->value = $event->wire()->sanitizer->pageName($title_field->value, Sanitizer::translate); } }); With these hooks PageRenameOptions will do its normal thing and sync the name field as I type a new title in the ProcessPageClone "Copy Page" form.2 points
-
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
-
Thank you for your answer and understanding! Yes, you´re right, it made me angry, because it´s totally against Processwire´s promise here https://processwire.com/about/why/ "The current CMS landscape and what’s wrong with it Still other products have APIs that introduce so many new types of tags, bits and scraps to learn, that we find ourselves in a template system that's trying to hide the underlying programming language from us–or worse–bypassing it completely. The perspective of ProcessWire is that PHP is the most familiar and powerful template engine we could ask for, so we enthusiastically embrace it.""2 points
-
Hi all, Media Manager Next/013 Sorry I haven't posted here in a while. I am currently working on the next version of Media Manager. It will part be refactoring and part be some new (some requested) features. I have been having some very helpful conversations with a number of you. Below are the current plans for the next version. Any other thoughts and/or ideas I should consider? It is a bit of work so I might have to stretch this into several updates (versions). Thanks. New Features Upload from external sources (Amazon, Google, etc.). Point media to external resource (e.g. to a video in YT, Vimeo, etc.). Independently set media title on upload Improve/extend media filter/profiles to MM Inputfields (possibly pick and apply a profile from a list) (thanks @gebeer) PDF thumb preview (thanks @gebeer) Upload and replace media (for single media MM inputfields). API (thanks @MrSnoozles) Any other thoughts.....? Refactor Remove dependency on JqueryFileUpload Remove dependency on jQuery -> use htmx and alpine JS instead. Easier to maintain for me as well as more flexibility. Improved preview of media and their properties. Better preview of media before upload. Redesigned GUI - Intuitive (like GDrive(?)), do away with media menus (use filters instead), need oMedia is just media. Remove/reduce use of modals. Allow grouping of media (link an album) <- not yet confirmed if will be implemented Implement hookable methods to allow easier developer control for those who need advanced/custom control of their MM. A number of reported bug fixes as well. ETA? I cannot give a firm date about this, sorry.1 point
-
Hi @Jim Bailie, Apologies for the delay in responding. Thanks for the interest in MM. There is a setting for what to do when an attempt is made to upload a media whose filename matches one that already exists in the Media Library. The current options are skip / rename / replace. This currently does not cover your use case. This is because currently the media page is automatically created (on upload) off of the file name. Hence, in your case, lion.jpg would create a new media page title Lion. A similar request to yours has been made with respect to replacing the media in a Media Manager inputfield that stores only one image. In order to replace the media, one has to first delete the existing single media. It would be more intuitive and easier to (similar to PW) to just delete the existing media by the new one. I am currently working on a new version of Media Manager that amongst other things will have an option to give uploaded media custom names instead of grabbing this from the file name. I can add your scenario usage to the TODO list for this next version.1 point
-
@bernhard yeah I'm gonna use it for my next PW project. But I was interested in the vite setup for my other projects, like when I'm doing just basic html integration with no CMS, but I still want to use sass, have my css preprocessed, using js module ect. I don't want a BIG setup, doesn't use tailwind, just the basics for building my assets and browser-sync1 point
-
Have you tried adding include=all to your children selector?1 point
-
In your selector the Repater Matrix Type is missing. Your "items" repeater matrix field needs to have some named "types" setup in the field configuration screen. The textfield is inside that type. If repeater matrix field "items" with type "image_text" has a field "textfield", your selector would look like: content_sections.items.type=image_text To get all pages that have items of type image_text you can use. $pagesWithType = $pages->find("content_sections.items.type=image_text"); To get all the texts you need to loop through those pages and get your textfield value foreach($pagesWithType as $p) { $term = $p->get('textfield'); } Or you can get an array of all terms like this $terms = $pagesWithType->explode('textfield'); Seehttps://processwire.com/api/ref/wire-array/explode/ EDIT: removed initial selector added code with loop etc1 point
-
Try this as a replacement for https://github.com/adrianbj/PageRenameOptions/blob/8665aca5023417163841603fda8037df2ccbe245/PageRenameOptions.module#L106-L108 Not well tested yet, but wanted to give you a better idea of what I meant. preg_match('/\(copy\s?\d?\)/', $p->title, $matches); $isTitleCloned = !empty($matches) && $p->name != $this->wire('sanitizer')->pageName($p->title, Sanitizer::translate); if(!$isTitleCloned && $this->data['initialDifferencesProtected'] && !$this->wire('user')->roles->has("name=".implode("|", $this->data['exemptRolesInitialDifferencesProtected']))) { $this->wire('config')->scripts->add($this->wire('config')->urls->PageRenameOptions . "InitialDifferenceProtected.js?v={$version}"); }1 point
-
@ryan, really great updates this week, thanks! WireSitemapXML sounds amazing. I saw this part in the docs: That would be a nice enhancement! Personally I would go for faster performance over greater convenience in hook arguments, but maybe there could be a config option so users could choose which they want to prioritize. Perhaps the page properties that are raw loaded and supplied to the hook methods can also be configurable so users can set what they need to distinguish pages in the hooks. A feature request: sometimes I want to get a plain list of all the URLs in the sitemap - for instance, to load into Xenu's Link Sleuth (I often use this as a simple way to prime ProCache). Maybe there could be a GET variable for that, e.g. /sitemap.xml?urls=11 point
-
Hi @Robin S - sorry for the really late response. Looks like your suggestion for matching the cloned name to its title works for me. Would you mind testing at your end please. Just add this at the start of the ready method. // if cloning a page, then set the name to match the title so Protect Initial Differences works $this->wire()->addHookAfter("Pages::cloned", function($event) { $p = $event->arguments(1); $p->setAndSave('name', $this->wire('sanitizer')->pageName($p->title, Sanitizer::translate)); }); This approach also works when the copy button allows one step ajax cloning. I'll look into your sync button idea as well.1 point
-
Hi @Stefanowitsch, is this the whole error message? Looks like the stack trace only.1 point
-
@qubism I wasn't sure if this particular feature was used. Sounds like it is -- I'll add it to TinyMCE.1 point
-
@kongondo Where are messages from MM actions like uploads etc are supposed to appear in the GUI? I mean messages that are generated during executeAjax(). I can see them as JSON response in the dev tools for requests to e.g. /processwire/media-manager/ajax/ like { "files": [ { "name": "csm_us_ziehmvisionrfdhybridedition-usa-forweb_1080x1080px_7c9dea3ab6.jpg", "size": 34682 } ], "count_total": 1, "count_success": 1, "count_fail": 0, "message": "error", "notice": "Media Manager: No valid media found to add to Media Library. If replacing media, check that they are not locked.", "nothingAddedYet": "Nothing added yet.", "action": "upload", "currentPageID": 0, "mediaManagerFieldID": 0, "insertAndClose": 0, "galleryID": "", "notice2": "Media Manager: Some media were not added because names already in use (csm_us_ziehmvisionrfdhybridedition-usa-forweb_1080x1080px_7c9dea3ab6.jpg)." } But there is no message output in the GUI after upload. In this case a duplicate image was ignored for upload. Are these JSON responses supposed to be shown as messages in the GUI? If not, it would be awesome if they could be shown to the user.1 point
-
Just to recap in case anyone else experienced this: After MM install I ended up with pages with wrong names (media-manager--audio, --document, --image, --video) under Admin->Media Manager. As a consequence all created media pages got saved under parent Admin->Media Manager->Media Manager:Audio. This also had an impact on duplicate media pages. They could not be detected. So no matter what the settings for duplicate media, all media got uploaded even if it was duplicates. I used this code to rename pages under Admin->Media Manager to have correct names like (media-manager-audio, -document, -image, -video) and move all media pages to live under their correct parent pages: // FIX wrong Media Manager page names under Admin -> Media Manager and sort media pages under correct parent $types = ['audio', 'document', 'image', 'video']; // fix page names from "media-manager--$type" to "media-manager-$type" foreach($types as $type) { $pID = $this->wire->pages->getId("parent.name=media-manager, name=media-manager--{$type}"); if($pID) { $this->wire->pages->get($pID)->setAndSave('name', "media-manager-{$type}"); } } // move media pages from wrong parent media-manager-audio to correct parent "media-manager-$type" foreach($types as $type) { // get all media pages under media-manager-audio parent $ids = $this->wire->pages->findIDs("parent.name=media-manager-audio, media_manager_{$type}!="); // put them under correct parent if(count($ids)) { $parentID = $this->wire->pages->getID("parent.name=media-manager, name=media-manager-{$type}"); if($parentID) { foreach($ids as $id) { $p = $this->wire->pages->get($id); $p->setAndSave('parent', $parentID); } } } }1 point
-
Hi, bringing this up again because I found the reason. On install of MM, the children under Admin->MediaManager got named "media-manager--image", --audio etc. No idea how this happended, though. Guess I will rename them manually. Since on upload the parent is defined by those page names, no parent is defined and all media gets saved under Media Manage:Audio. A check in MediaManagerActions.php around L1575 for $parent instancof NullPage or the like would be great to at least issue a warning. Consequently the checks for duplicates on upload did not work. This is how I discovered the root cause.1 point