-
Posts
691 -
Joined
-
Last visited
-
Days Won
6
thetuningspoon last won the day on November 3 2022
thetuningspoon had the most liked content!
About thetuningspoon
- Birthday 11/03/1986
Contact Methods
-
Website URL
https://si.design
Profile Information
-
Gender
Male
-
Location
CT, USA
-
Interests
Design, Programming, Tiny Houses, Architecture, Music
Recent Profile Visitors
15,814 profile views
thetuningspoon's Achievements
-
Hi @mel47, I just pushed out a release that I believe fixes this. Can you confirm? It looks like there was a small issue with @kixe's pull request a while back that I didn't catch.
-
Using custom Page class methods on repeater items
thetuningspoon replied to johnstephens's topic in API & Templates
There is a workaround if you're willing to edit the core: https://github.com/processwire/processwire-requests/issues/239 -
thetuningspoon started following Using special characters in selectors , PW 3.0.218 – Core updates , Putting page hooks in Page Classes and 2 others
-
I'm getting the following error after upgrading: Fatal Error: Uncaught Error: Class 'FieldtypeFile' not found in wire/core/Modules.php:700 #0 wire/core/Modules.php (1478): Modules->newModule('\Fie...') #1 wire/core/Fieldtypes.php (199): Modules->getModule('FieldtypeFile') #2 wire/core/Fields.php (203): Fieldtypes->get('FieldtypeFile') #3 wire/core/WireSaveableItems.php (260): Fields->makeItem(Array) #4 wire/core/Fields.php (255): WireSaveableItems->initItem(Array, Object(FieldsArray)) #5 wire/core/WireSaveableItems.php (953): Fields->initItem(Array) #6 wire/core/WireSaveableItems.php (469): WireSaveableItems->getLazy(434) #7 wire/core/Fieldgroup.php (127): WireSaveableItems->get('434') #8 wire/core/Fieldgroup.php (380): Fieldgroup->add('434') #9 wire/core/WireSaveableItemsLookup.php (135): Fieldgroup->addLookupItem('434', Array) #10 wire/core/WireSaveableItems.php (953): WireSaveableItemsLookup->initItem(Array) #11 wire/core/WireSaveableItems.php (469): WireSaveableItems->getLazy(3) #12 wire/core/Template.php (796): WireSaveableItems->get(3) #13 wire/core/Templates.php (132): Template->setRaw('fieldgroups_id', 3) #14 wire/core/WireSaveableItems.php (260): Templates->makeItem(Array) #15 wire/core/WireSaveableItems.php (953): WireSaveableItems->initItem(Array) #16 wire/core/WireSaveableItems.php (469): WireSaveableItems->getLazy(3) #17 wire/core/Templates.php (252): WireSaveableItems->get(3) #18 wire/core/PagesLoader.php (1241): Templates->get(3) #19 wire/core/Pages.php (217): PagesLoader->getById(Array) #20 wire/core/ProcessWire.php (625): Pages->init() #21 wire/core/ProcessWire.php (582): ProcessWire->initVar('pages', Object(Pages)) #22 wire/core/ProcessWire.php (315): ProcessWire->load(Object(Config)) #23 index.php (52): ProcessWire->__construct(Object(Config)) #24 {main} thrown (line 700 of wire/core/Modules.php) I tried emptying the cache folder. FieldtypeFile definitely exists in the wire folder. I also tried programmatically reloading the modules in ProcessWire.php right before Pages->init() where it fails by calling $wire->modules->reload(). This was the error I got: Error: Exception: Unable to create path: /reload/ (in wire/core/CacheFile.php line 64) #0 wire/modules/Markup/MarkupCache.module (103): CacheFile->__construct('/', 'reload', 3600) #1 wire/core/WireArray.php (2263): MarkupCache->get('reload') #2 wire/core/WireArray.php (2445): WireArray->explode('reload') #3 wire/core/Wire.php (419): WireArray->___callUnknown('reload', Array) #4 wire/core/WireHooks.php (952): Wire->_callMethod('___callUnknown', Array) #5 wire/core/Wire.php (484): WireHooks->runHooks(Object(Modules), 'callUnknown', Array) #6 wire/core/Wire.php (487): Wire->__call('callUnknown', Array) #7 wire/core/ProcessWire.php (582): Wire->__call('reload', Array) #8 wire/core/ProcessWire.php (315): ProcessWire->load(Object(Config)) #9 index.php (52): ProcessWire->__construct(Object(Config)) #10 {main} Very strange.
-
module Pre-Save Validation (AdminPreSaveValidation)
thetuningspoon replied to thetuningspoon's topic in Modules/Plugins
Just released v1.1.0 with support for automatically switching to the tab that contains the first error. This way editors won’t be confused if the error is on a different tab from the one they’re currently on.- 1 reply
-
- 4
-
@bernhard This looks very cool. How does it know to only register the hook once when you're working with multiple pages of the same class?
-
I've taken to just creating a separate file called PageClassNameHooks.php for each PageClassName.php that needs hooks and then including it in init.php. Keeps things organized at least, and you can be sure they won't be initialized more than once.
-
@DV-JF https://github.com/processwire/processwire-requests/issues/239
-
@bernhard Thanks for the clarifications. I think we are on the same page now. Regarding the order agnostic application of migrations, I had assumed that it was not order agnostic because of something you said to me in the RockMigrations thread about defining dependencies after creating fields/templates. does this also work when you have migrations spread across multiple files? I guess I am also a bit confused about the difference between using the migrate() function and using the createField() and createTemplate() functions. Is it just a matter of preference or are there differences in how these are processed (i.e. do you need to put everything in a single migrate() in order for it to be order agnostic)? I didn't see anything about the difference between these functions in your documentation and it took me a while to figure out that I should use the migrate function when copying and pasting the data from the field/template back end editor.
-
Sorry, I didn't see this comment before my previous post. I know that RockMigrations does not remove fields and templates unless you explicitly request it to. Does RockMigrations support the additional features I mentioned? Automatic update of config files when changes are made in the admin (I know it offers the copy & paste feature, which is a great start and preferable when using multiple migration files) Order-agnostic migration Field/template cleanup function for those not defined in migration files Option to only apply changes manually via cli or button press in admin
-
@bernhard I know you've put a lot of work into your module and I can see why my post pissed you off (to be honest, after I posted it I thought about removing it because I was worried this might happen). I did "test drive" RockMigrations last week. Unfortunately, my test drive started with me trying to create and migrate a ProField for a project I'm working on, and the result was that my new field's settings were wiped out each time the migration ran. Then I read a post you wrote that made it sound like you didn't plan on supporting ProFields and didn't understand why anybody would have need for them since you don't use them yourself. All of our projects use ProFields, so it's a showstopper for us if these aren't going to be supported. And I don't feel like I should really have to justify that need and I'm not interested in arguing about it. That's why the system that I have in mind would use the existing JSON export/import mechanism from the core, which already supports migrating ProFields, and presumably will continue to support any new 1st party field types that are built. It would just bolt onto it and make the export/import process more automated. And as I described in my last post, it would be agnostic about the order of the field and template definitions so the user wouldn't have to worry about dependencies with order of import. So I'm not really sure what to say. There's no reason why we can't have more than one approach to this. You're saying that you're interested in feedback, but then it feels like you're mocking our ideas. If you think our ideas are stupid or too limiting or whatever, then at least let us have fun with them on our own :-) EDIT: I just looked over the processwire-requests thread on Github again and I see that some other people who have gotten deeper into this already have reported issues with the core JSON export/import module that would need resolving before certain fields could work. Other than the FieldtypeOptions I haven't had many issues lately in my experience. I also saw that you expressed interest in supporting the Combo field in that thread, so I apologize if I've misinterpreted. If RockMigrations can support my fields and desired workflow with just a bit of additional development (from either you, me, or someone else), then I would certainly prefer that to having to write a new module from scratch! Also, I have to say that your car analogy had me in stitches after reading it fully from start to finish. :D I agree in theory, but I would personally rather err on the side of caution. Neglecting to delete a field or template doesn't effect the operation of the system, but deleting one unintentionally (I'm picturing something like a merge conflict being resolved incorrectly) would require restoring from a backup. I see the list of deleted templates/fields as still declarative in the sense that it doesn't matter what order they're in or when they're added. It's just saying "these fields and templates should never exist". Anyway, I can see wanting it to work either way. So this could simply be a matter of a setting in the module.
-
I've been thinking about this and I think any declarative configuration system should be extremely conservative about removing any data from the database. One way of handling this would be to have a separate location in the config for listing out the names of templates and fields that you explicitly want to remove. If an install contains a field or template not in the configuration or in the removal list, it would simply ignore it. Another approach would be to ignore any field or template not in the config, and provide a separate "cleanup" function that could be triggered with a button in the admin or a cli command. This would go through and remove any fields or templates that are not listed in the config. While the config files could be updated automatically as changes are made in the admin interface, I think that any outside changes to the config files should require a manual sync and not be applied automatically. A notice in the admin could alert the superuser that the config file contains unapplied changes and then they could click a button or use a cli command to apply the changes. The algorithm for adding new fields and templates should first check for the existence of each field and template by name. If one is missing, it should proceed to create the field or template and with its name and type (but no other settings). After that it can go back and apply the settings for everything, at which point dependencies between fields and templates should resolve without issue (family settings, page fields that reference templates in their settings, etc.). I've been tempted to try working on a module for this for a while now and was close to having a project that required it at work that would allow me to invest the time into it. That project is currently stalled but may still come about at some point at which point I could try working on this if someone else hasn't already gotten to it.
-
module Pre-Save Validation (AdminPreSaveValidation)
thetuningspoon posted a topic in Modules/Plugins
Github: https://github.com/thetuningspoon/AdminPreSaveValidation This module prevents admin editors from saving changes to a page that has one or more invalid fields. It uses an ajax call to check for errors and javascript to populate the page edit form with any error messages that were returned. This way the user can correct the issues and resubmit the form without invalid data getting saved to the database or the editor losing changes. I've wanted a way to implement this common workflow in ProcessWire for some time now and this relatively simple ajax-based approach makes it possible without getting too much in the way of how ProcessWire normally works. For example, all of the post-save actions (Save + Exit, Save + View, etc.) still work as usual. The only downside is that a successful save will take a bit longer as it involves two sequential http requests (the initial ajax request that checks for errors and the normal page submit after no errors are returned). This module has also been tested successfully with repeaters and other nested inputs. By hooking after Inputfield::processInput, you can add your own custom validations to inputfields and this module will pick up on and display them as well. /* * Example of hook that adds an error to an inputfield. This will add an error to every input. */ $this->wire()->addHookAfter("Inputfield::processInput", function(HookEvent $event) { $event->object->error('Invalid input!'); }); I hope others will find this module useful!- 1 reply
-
- 15
-
@bernhard Great video! The thing that I was confused about with RockMigrations (and the video doesn't address directly but I think I'm finally understanding anyway) is that it is about declarative template/field configurations that can be modified at any time rather than a series of instructions for updating PW. (When I think of the word "migrations", it makes me think more of files or snippets of code that apply a certain sequential set of changes for a specific feature.) So I my question now is, can I just have a single migrate.php file that has ALL of the fields and templates defined in it? Or maybe a separate file for fields and one for templates? What's the advantage of tying the migration with the page class like you did in the video vs. doing it that way? (I can see how if you built a feature you wanted to use on multiple sites (like a shopping cart) that having a separate migrate function would be better for that). My other question is what is triggering the migration to run in your video? Does the default migrate.php file just run on every page load, or just in the page editor? I would probably only want it to run via CLI. Thanks!
-
Weekly update – 30 September 2022 – Invoice app profile
thetuningspoon replied to ryan's topic in News & Announcements
Very cool. I developed something like this for Solution Innovators, along with a front end for our customers to view their invoices and pay off their total balance. I like how you modified the page editor here. I used separate pages for the invoice items and payments instead of repeaters because I found repeaters difficult to work with when summing and reporting data, and also mapping them to models required some hacking (or did at the time - https://github.com/processwire/processwire-requests/issues/239). How are you handling this? (or is that beyond the feature set of this project?) We also built our whole time tracking software on ProcessWire :) -
The way around this should be to use a selector array instead of a selector string. However, I've been having problems using selector arrays to match titles that have characters like dash (-) and pound (#). Not sure what's happening there.