Leaderboard
Popular Content
Showing content with the highest reputation on 02/07/2024 in all areas
-
By the way, I had a private conversation with @elabx in which we discussed the Migrations module a bit more. Since it said "deprecated in favor of RockMigrations", I originally didn't look into it further. This was a mistake! It basically does exactly what my module does. Just better. And there is absolutely no reason not to combine it with RockMigrations! I have forked that module and put in some early work to update it to namespaces and PHP7/8 compatibility. I might talk to @LostKobrakai to maybe take over or provide some PRs to keep it alive since there is a commercial incentive now. https://github.com/poljpocket/Migrations/tree/pw3-php8 note the work is just on a separate branch for now.3 points
-
Hi Bernhard, lots of questions ? I am happy to answer! Right now, we are using my module and in the not so distant future, probably the Migrations module. Always me, the team lead. We are planning to use GitHub actions soon though. I think this workflow makes sense and I can't come up with a different approach. Sure, most of the migrations probably work just fine if executed several times and for those, we could use vanilla RockMigrations. I can even give you two good examples. Note that I can't share code since these are both commercial projects: Featured images Right now, we have an ongoing project where we as a first phase, finished the editing experience for a products list (not a shop, but many of the same features). We have included a product gallery and for the longest time, it was fine to just use the first image uploaded as the featured image. Then, we ran into some problems with images having unfortunate subject placements which made the first image with the same settings not compatible with the featured image concept as it was. This forced us to create a new image field where we can set another focus point and sizing constraints. Since the client had finished inserting 200+ products already, we simply cannot ask them to just upload the first image (or possibly a new one) for every product again. The snippet in question which only can be ran exactly once is: "duplicate" the first image on disk, resize to match new constraints, set it as the featured_image, copy over focus point settings (which is fine for most, but not all). Everything else (create field, add to template, ...) is done with RockMigrations. Why can I run this only exactly once: From this point on, the client will start uploading possibly different images to featured_image and change some of the settings where the original ones don't work out. If we ran this procedure a second time, all that work is gone and the filesystem/database is possibly in a corrupted state. Combining multiple fields into one with specific markup For another project, we had some references set up with a very sophisticated mask for inserting info like the client, the year and some more meta information. Some spec change for this forced us to combine all of this information into a single rich editor to allow for more flexibility and customization. Again, much of the content management has already been done at this point and we couldn't just ask to do it again the "new way". The snippet which only can be ran exactly once is: render the fields together as markup and set to the body field remove all fields not needed anymore (with RockMigrations) Again, everything else (add to template, configure field in context, ...) is done with RockMigrations. Why can I run this only exactly once: This one is a bit less clear as this migration might be gated with a simple if (e.g. are the fields still on the template or not). But still, it is easier to just make sure it doesn't run more than once.2 points
-
As a note here: https://blog.jquery.com/2024/02/06/jquery-4-0-0-beta/ "Totgesagte leben länger" (those who were declared dead live longer) There also cut some old dependency. Maybe an interesting development.2 points
-
Hi all. I have decided to publish one of the plugins I have been working on in my free time during the last few days but actually was motivated by our needs at work. It is currently in early beta and much of the functions might be subject to change. Before you jump at my throat and tell me that I am copying RockMigrations by @bernhard, please read on! System Config Versions This module adds an admin interface for developers to manage configuration revisions. Think of it as git for PW configurations ?. It ensures that revisions only get run once. It is possible to run multiple revisions up to a certain point or even all available ones. Aren't you just copying RockMigrations? No. I made this plugin because at work, we needed more precise control over migrations and also do a lot more in migrations than adding&removing structural configurations. Often times, we use small snippets to change field data throughout the process of creating websites. And these may only be run exactly once. Actually, we are usually using RockMigrations alongside this plugin to use it's very impressive function set! Think of this plugin as a way to persist run status for any migrations and ensure any migration only ever gets run once. Simple Case Study The motivation behind the module is best described with a code example: <?php namespace ProcessWire; /** @var RockMigrations $rm */ $rm = $modules->get('RockMigrations'); $rm->createField('richtext', [ 'type' => 'FieldtypeTinyMCE', // ... ]); $rm->addFieldToTemplate('richtext', 'basic-page', 'textarea'); $pagesToUpdate = $pages->find('template=basic-page'); foreach ($pagesToUpdate as $pg) { $pg->setOutputFormatting(false); $pg->set('richtext', $pg->textarea); $pg->save(); } $rm->removeFieldFromTemplate('textarea', 'basic-page'); The goal of this revision file is to convert an existing textarea field of all `basic-page`s to a richtext field. The code snippet which maps the contents of the fields is obviously part of the revision and with bare RockMigrations, we have no control over how many times it gets run. With SystemConfigVersions, the snippet gets run exactly once. More Info & What's next? For usage instructions and details, refer to the repo's README. Do you guys have any first impressions or any recommendations or ideas for this project? Is there even a need for it in a broader sense? You can find the GitHub repo here: https://github.com/poljpocket/SystemConfigVersions Some ToDo's as of now: URGENT: Greatly improve error handling Add GitHub Actions support to automatically apply all new versions Add ability to reset run status down to a certain point Revise documentation below Add configurability for versions folder location and file naming scheme Add folder as version support (e.g. all files inside a version folder are executed and treated as one revision).1 point
-
No not at all. Just for local development. EDIT: not at all = no, we don't use docker for deployments. Main reason: Most of our clients won't pay for the increased cost of a cloud platform. Second important reason: Most of our projects in the end are "just websites" and for that, the bells and whistles a shared hosting environment provides on the cheap are just too good to not use (e.g. email sending without a complicated configuration, managed configuration and automatic updates, and HTTPS support with auto certificate renewal). Also, you can look at some of the other docker topics I have answered on the forum, PW doesn't play too well with cloud environments (e.g. problems with session retention due to the proxying CEs use). I could be wrong, but I haven't digged into it more than I needed to in order to have a clean and simple local docker environment.1 point
-
Thx for trying to explain the details. I understand you well. This is why I built RockMigrations. On the last sentence I'm losing you. I'd still be interested in a detailed example of what you are doing and where this is necessary and why. You are explaining extensively the same workflows that I'm using and then you suddenly state that something is missing without going into detail. For example: How to you execute these snippets? Who does it? Did you think of any different approaches? Why do you think this has not been an issue for me so far?1 point
-
You might find this useful: https://processwire.com/modules/page-rename-options/1 point
-
I'll add, perhaps for @ryan to consider, that an equally good solution would be for ProcessWire to borrow a behavior from elsewhere. In WordPress if I want to reset a slug I just clear the field and save the post. It then auto-populates that field from the post title as it does when the post is first created. In ProcessWire clearing the slug fields and saving the page just reverts the fields to their prior state. A small, but nice feature in WordPress I'd love to see in PW. :)1 point
-
Maybe you have "use" statements replacing the missing namespace? Or maybe there's something different in composer.json configuration?1 point
-
For your goals: $files->getCSV() - https://processwire.com/api/ref/wire-file-tools/get-c-s-v/ Images are a little trickier but if you know where they are stored on the server there's just a little post processing required. https://processwire.com/modules/process-page-field-select-creator/ - then populate the child template with fields you need editing As said above, turn off formatting, then you can iterate through using $pages->findRaw() and implode(), etc. https://processwire.com/api/ref/pages/find-raw/ Write to files using $files->putContents(); https://processwire.com/api/ref/wire-file-tools/file-put-contents/ Using a dedicated table breaks one of the features of PW vs WP - every field is a table! https://processwire.com/blog/posts/making-efficient-use-of-fields-in-processwire/ That being said, if you wanted to create a special field that compounded a bunch of related values together, you could look at this module: https://processwire.com/modules/fieldtype-events/ If you are looking for a tutorial that includes creating a custom class to store your value, a more advanced overview is here:1 point
-
You can use my composition as a starting point. It has a configurable ProcessWire version (must be a tagged one on GitHub) and supports DB dumps for complete version control. Be advised this is intended for local development and NOT for production! You should be able to add SSL and some more hardening to make it production-ready though (for sure remove the phpmyadmin container!). poljpocket/processwire-docker: Docker installation of ProcessWire for local development (github.com)1 point
-
Preventing a page from being moved is not necessarily a straightforward matter of trapping the change in a save hook in the same way as a page edit. A problem occurs if the page is only to be 'blocked' conditionally - when the page path is in some given array, for example. In hooking before page save, the page path is the new page path after the move, rather than before it, so you need to do something like this: // .... In the before page:saveReady hook // $page is the page :) The code below operates when (isset($page->parentPrevious) && $object->parentPrevious != $object->parent) $name = $page->parentPrevious->path . $page->name . '/'; // need the path before it was moved if(in_array($name, $blockedNames)) { // $blockedNames are the ones where we don't want moves // Because this hook operates after the move, we need to reverse the move $page->parent = $page->parentPrevious; // Alternatively, to completely stop the save //$event->replace = true; //$event->return = false; } //... rest of hook This prevents the page being moved, both in the page hierarchy (by dragging) or in the page editor by changing the parent in the settings tab. It is also possible to hook before Page:moveable with something like this /** @var Page $page */ $page = $event->object; $moveable = $event->return; // ... code to set $moveable to false if conditions met $event->return = $moveable; Interestingly, the (not documented?) moveable method is created as a hook by PagePermissions and so is hookable. However, this method appears to catch only the situation where the move is effected by dragging the page in the tree, not when the parent is changed in the settings.1 point