Building a better workflow: Fun with third parties
OK, so looking back we were perhaps a little optimistic.
Once we had a proof of concept we got carried away and thought we'd have this thing licked in a couple of weeks. Then we started on third-party field type support and things started to look a little different. I say third-party field types but in fact, as is so often the case in real life, our problems really started with relationships.
We all know that documentation is at best only a vague guide as to what a feature will do, but the hook 'entry_submission_ready' is described by EE as "Additional processing after all data has been validated, just prior to insertion / update". Just prior, huh?
What this doesn't tell you is that before this hook is called the Channel Entries API calls a function called _build_relationships() which updates the relationships table. If you're trying to create a draft of an entry without effecting the live version this is a bit of a problem. We had to use this hook as our departure point because 'entry_submission_start' didn't come with all the required data and 'entry_submission_end' was just too darn late.
It took a fair amount of hair pulling but we finally figured out a way do stop EE updating our live relationships. If you're really bored or super geeky I'm more than happy to share this with you (just drop me a line), but suffice to say it involved stowing our new data out of the way for a while and they adding it back in later.
It was then time to look at third-party field types and we decided to start with everyone's favourite, Matrix. The big thing about third-party field types like this is, just like native relationships, they store their data in their own tables and have a whole bunch of pre and post processing. We needed to find a way to getting the field type to do its thang but intercept it at a crucial moment and stop it saving its data in the usual way.
When it came to creating a draft we used the 'entry_submission_start' hook and looped through the data looking for Matrix fields. Now, because Matrix columns can be many different input types (text, files, dates, WYSIWYG) we had to run type specific pre-processing. To do this we wanted to call the native methods within Matrix but unfortunately some of these were private so we had no choice but to duplicate some code. Once we'd run these methods and had nice clean data we saved it in our own generic third-party table.
For our draft preview Brandon Kelly, the creator of Matrix, gave us a Christmas present in the form of the (little known?) 'matrix_data_query' hook. This little beauty meant we could stop the normal process, replace the live data with our saved, draft data and then give this back to Matrix to finish rendering the template. Mmmmmmmm, we love hooks.
As it stands our Matrix support is pretty good and involves no changes to its code or the core. Our AJAX preview means we need to do a little DOM manipulation to make sure our Matrix rows constantly reflect the saved data but we're pretty confident we can get that bit resolved.
We haven't started on Playa yet, but reading this post from Brian Litzinger, who is working on a similar add-on, it sounds like we may be searching in vain for equivalent hooks. He's created some of his own and we're hoping to copy his pattern for these. The way we see it, EE today is as much about the third party add-ons you install as the core itself. The core has a standard set of hooks which we all use, why not create a standard hook structure within third party add-ons? This could open up all sorts of possibilities for multi add-on integration.
We had such a positive response to our initial post of BetterWorkflow and I know there are a bunch of people out there who are really keen to beta test and start using this. I'd love to give you a date for a beta release but the truth is this is taking much longer than we anticipated and we don't want to put it out too soon. On top of this Electric Putty has won recently a couple of exciting new projects so our time is going to be largely devoted to client work. Please bear with us, we really do want to get this out there and we promise, we'll keep you all in the loop.
In the meantime here's a quick (4 minute) demo of the BetterWorkflow in action.
Many thanks, Malcolm
9 comments
Ian Pitts
This is exactly what I’m looking for! It’s great to see the progress with this and I’m on the edge of my seat waiting to get my paws on a beta! *hint hint*
Brent
Brilliant! I’d pay for it as-is without the workflow stuff! I’d be happy to help test as well if you need it.
Marc Tanis
This is a game changer. You guys have done great work.
Cem Meric
Great functionality guys. Now, when can we buy it! :)
Let us know if you need beta test/feedback?
Ibn Saeed
Seems pretty stable right now
Id pay for it as well.
FCL
holy wow this is perfect! i’d gladly pay through the nose for this. definitely a game changer that will take ee to the next level. any updates on when a beta version will be ready for testing?
cheers.
Emily
My company would also be very interesting in paying for this, and beta testing if that is an option. Any updates on when it might be ready for beta?
Chad
This is exactly what I need also. :|
Would be fantastic if I could get a beta copy of this, and of course, willing to pay for it.
John de Beer
Brilliant stuff. Happy to help with beta if you want.