Leaderboard
Popular Content
Showing content with the highest reputation on 02/01/2023 in all areas
-
Hi, you can add a hook to execute code whenever a page is moved to the trash. You can use this to check how many children are left and send an e-mail using WireMail. Put this in your ready.php: $this->addHookAfter('Pages::trashed(template=calendar-post)', function(HookEvent $event) { $numberOfItems = wire('pages')->count('parent=/daily-menu/'); if ($numberOfItems <= 7) { $m = new WireMail(); $m->to('chefdecuisine@example.com'); // specify CSV string or array for multiple addresses $m->from('noreply@example.com'); $m->subject("Uh-oh, there are only {$numberOfItems} dishes left on the menu"); $m->bodyHTML("<html><marquee><blink><a href='" . wire('config')->urls->admin . "'>DO SOMETHING QUICK!!!</a></blink></marquee></html>"); $m->send(); } }); Obviously if you trash items one by one, you’ll get one e-mail for every item as long as the total is under 8. A more proper way to do this may be a cron job that only checks once a day. Alternatively you may not need to send an e-mail at all? Perhaps it will suffice to show a message to the user who did the trashing? wire()->message('Please remember to complete the daily menu! There are currently only {$numberOfItems} dishes.'); You could show this just after trashing or simply all the time whenever there are too few items.3 points
-
Hello everyone! Recently I wrote these scripts for TracyDebugger console in order to make work with RepeaterMatrix easier and faster. I want to present them to the community. Show relationship between all types, names and labels. $repeaterMatrixModule = $modules->get('FieldtypeRepeaterMatrix'); $fieldName = 'content_blocks'; $repeaterMatrixField = $fields->get($fieldName); $typesArray = []; foreach($repeaterMatrixModule->getMatrixTypes() as $matrixName => $matrixType) { $typesArray[$matrixName] = $matrixType . ' ' . $repeaterMatrixModule->getMatrixTypeLabel($matrixType, $repeaterMatrixField); } db($typesArray); Show all pages which have specific type in field (repeater_matrix) with this name: $repeaterMatrixModule = $modules->get('FieldtypeRepeaterMatrix'); $typeName = 'block_text'; $fieldName = 'content_blocks'; $repeaterMatrixField = $fields->get($fieldName); $typeId = $repeaterMatrixModule->getMatrixTypeByName($typeName, $repeaterMatrixField); $typeLabel = $repeaterMatrixModule->getMatrixTypeLabel($typeId, $repeaterMatrixField); $pagesWithType = $pages->find("{$fieldName}.type={$typeName}"); db($pagesWithType); db($typeLabel, 'Name of type'); This list can be continued as soon as I'll invent more scripts.2 points
-
@BrendonKoz, you can use the hook below to target the children() selector used in PageListSelect/PageListSelectMultiple and remove the "status" clause that allows unpublished and hidden pages. Because those inputfields use ProcessPageList the tricky part is only affecting the inputfields and not the main page tree. After some digging I found that you can distinguish these cases by a "labelName" GET variable. $wire->addHookBefore('ProcessPageList::find', function(HookEvent $event) { $selector = $event->arguments(0); $name = $event->wire()->input->get('labelName'); if($name === 'your_page_reference_field_name') { $selector = str_replace(', status<9999999', '', $selector); $event->arguments(0, $selector); } }); Before: After:2 points
-
whoops, sorry, I typed that straight into the forum textbox, pretty happy anything works at all ? I’ve changed the quotes above, so you should be able to copy it, @Roych PHP’s equality operators are == and ===. This is a classic foot gun, there’s probably even a name for it… Your idea should be fine unless there’s some sort of bulk-trash feature that I don’t know about where the number of children could go from 8 to 6 in one go.1 point
-
1 point
-
@Macrura There is a console.log($(this)); left in simplemde_init.js: https://github.com/outflux3/FieldDescriptionsExtended/blob/f550084f25ea32cecfe0b9879bf46bc23b3b03ac/simplemde_init.js#L12 Next time you update the module, could you please comment it out? Pretty useful module, BTW. Thanks for sharing!1 point
-
I'm not sure whether it's intentional or not, but I started experimenting with deploying a site setup to a clean, blank copy of ProcessWire with RockMigrations I dumped a copy of RockMigrations and a custom module with a migration file in the format MyModule/MyModule.migrate.php I installed RockMigrations via the admin UI, and was wondering why it was taking so long. Afterwards I checked, and found it had gone ahead and installed all the modules, fields, files, and created pages in the custom module's migrate file, even though the module itself was not yet installed. I'm not sure whether that's intended behaviour? If it is, I need to make sure I don't upload a module with a migrate file unless I want the migration to run as soon as I upload it. My assumption was that RockMigrations would start watching and running migrations in a module's directory once the module is installed, but possibly I assumed wrong. Apart from being surprised that the module's migration file ran before the module was installed, it was very nice to see a whole app with multiple fields, templates, modules, and pages constructed before my eyes, and it's way more modular than exporting site profiles, since I can build a base functionality in one migration file and then add components in others.1 point
-
@gebeer, thank you for improving my scripts. I've updated them. Also my previous version of this script finds pages in repeaters which is not an intended behavior.1 point
-
I found the reason. It works if you only have 1 repeater matrix field. If you have multiple, you need to pass the field object as 2nd parameter: $field = $fields->get('content_product'); $repeaterMatrix = $modules->get('FieldtypeRepeaterMatrix'); $typeId = $repeaterMatrix->getMatrixTypeByName('teaser_gallery', $field); Same goes for $repeaterMatrix->getMatrixTypeLabel(string 'typename', Field $field)1 point
-
Thanks for sharing. Your 2nd example can also be written like this $fieldName = 'content_product'; $typeName = 'product_downloads'; $pagesWithType = $pages->find("{$fieldName}.type={$typeName}"); db($pagesWithType); No need for looping through all pages. find() accepts the subselector .type. Only drawback with my solution: you don't get the label for the type. Actually when trying your example, $typeId returned false and $typeName returned null $repeaterMatrix = $modules->get('FieldtypeRepeaterMatrix'); $typeId = $repeaterMatrix->getMatrixTypeByName('product_downloads'); db($typeId, '$typeId'); // returns false $typeName = $repeaterMatrix->getMatrixTypeLabel($typeId); db($typeName, '$typeName'); // returns null Which version of Repeater Matrix are you using?1 point
-
That is mighty impressive. I'm going to look this over more carefully later this evening, but (1)that's awesome, and (2)I was apparently looking in the completely wrong place(s). Ugh. ?♂️ Thank you so much, Robin! This will undoubtedly prove useful now, and in the future. UPDATE: It's 3 days later and I finally had an opportunity to look at this and give it a shot. I'm still lost on how Robin maneuvered through the file structure to identify where to adjust the call - that's some magic there - but I'd just like to clarify one thing: This hook doesn't allow you to target a specific template (PW conditional hooks); nor was I able to find a passed value to access the intended template (I did find a value, but when trying to access it directly, I only got a null value), so unless someone discovers how to target the intended calling page's template, this would be best for overriding only a field that is going to globally be overridden in this manner. Other than being aware of this, it works great!1 point
-
Since I had to update more and more projects lately and also the PHP version of some of these projects was set to >=8 in the meantime I created a fork of the module and updated mPDF to version 8.1.3. With only some small changes in the WirePDF module I can now continue to use Pages2PDF without any restrictions. Maybe this is helpful for someone. https://github.com/markusthomas/Pages2Pdf1 point
-
$pages->get(1)->url; This returns the Home page url.1 point
-
Hi matjazp A late answer to your question. I came across the same issue as you. I wanted to set the width attribute of my images to 1280. But what I found was that CKEditor has a maximum allowable value for the width attribute. And that maximum value is 1200 pixels. If you go to: wire/modules/Markup/MarkupHTMLPurifier/htmlpurifier/standalone/HTMLPurifier/ConfigSchema/schema.ser There look for this bit... "HTML.MaxImgLength";i:1200 Change 1200 to your desired maximum value. Worked for me at least! Hope that helps Regards Zahari M.1 point