There are certain use cases where it can be beneficial to alter the IPE commands after the form is saved, e.g. to integrate with Workbench Moderation to force the latest revision is loaded.
There are certain use cases where it can be beneficial to alter the IPE commands after the form is saved, e.g. to integrate with Workbench Moderation to force the latest revision is loaded.
Comments
Comment #1
damienmckennaThis is for use with #2362651: Add revision support to panelizer entity pages that use IPE.
Comment #2
damienmckennaIs there another way of doing this?
Comment #4
michelleI tested this and the patch still applies cleanly. If I make a function test_panels_ipe_ajax_save_commands_alter(), it gets called. So that much works.
But the function hook_panels_ipe_ajax_save_commands_alter() never runs so the code in there to redirect to the home page doesn't run. Is it supposed to? I'm not sure how that code is even related to this issue or why you want to have the redirect. If you're using IPE, wouldn't you want to stay on the same page after saving?
Comment #6
eclipsegc commentedOk, I wrote REALLY similar code to this earlier today for functionally similar reasons (workbench_moderation being the bane of my existence) and had fairly limited success because the cache is still locked, which makes redirects semi-non-functional. This lead to trying to turn off the lock which looks like it can be done via ajax, but my kung fu failed me there, so I sat and thought about it for a while. Seems to me the more important thing here is that panelizer (and really any module that's going to interface with panel renderers) needs to have a bit of code that gets consulted during the save process. This is pretty entangled no matter how I cut it, so this patch is a rough "what if" scenario. Since we can't do panelizer plugins per bundle, this still doesn't quite get as far as letting workbench_moderation get what it needs out of the situation, and now I'm expecting these sorts of plugins to account for every renderer out there (easy when we only have 2 or 3, but fundamentally a design flaw in my suggestion here which I acknowledge). Still if we replaced my code here with a call to some method on the plugin, we could get similar results and not require IPE to special case each plugin type that might come along.
Let me know what a better solution is.
Eclipse
PS: In this code, workbench_moderation would need to hijack node's uri callback and nuance the return so that node/%node/draft and the various available revisions could be properly forwarded to, but at least this makes it possible.
Comment #7
eclipsegc commentedOh, and to illustrate the problem here, panelizer and IPE (workbench_moderation or no) have an integration issue around revisions right now. If you were to "Customize this page" add a pane, save and then customize the page and add another pane (all without ever refreshing) you'll end up with a block that has no controls on it, and that block won't show up in any of your revisions because IPE is saving it to a cache we don't ever use again (I think...) My solution in the above patch is a brute force page refresh for the sake of absolutely proving I can kill the problem. A more elegant solution hopefully exists.
Eclipse
Comment #8
eclipsegc commentedAlso, apologies I kind of hijacked this issue since I think we have the same ultimate goal, if not I'll start my own issue. :-D
Comment #9
damienmckenna@eclipse: That's ok, my suggestion was purely from the POV of getting it to work better with Panelizer and WM, so if there's a better way then I'm completely ok with it.
Comment #10
joelstein commentedHere's a patch that runs with DamienMcKenna's idea, but expands on it to a single hook to alter all ajax commands issued by IPE.
For example, you could implement this in a module to redirect after saving or changing layout:
The patch looks like I changed a lot, but that's just because I had to wrap some stuff in if/else statements so we could get to end of each ajax method where the commands are altered.
@EclipseGc: FYI, you can invoke hook_panels_cache_save() to add code which gets consulted during saving.
Comment #11
eyilmaz+1 for patch in #10. Must have to make panelizer with revisions work smooth.
Works for us.
Comment #12
joelstein commentedThanks for the review! One use case I use in lots of projects with this patch is to automatically re-initialize IPE editing after changing layout, because I've found that's what most of clients do right after changing layout.
With this patch, you can easily do something like this:
Comment #13
kopeboy@joelstein you might want to see the specific issue I created for this
#1572202: IPE changes aren't shown after second save without page refresh
Comment #14
japerryI'd like to see some more reviews before committing this. Taking out of RTBC queue for 3.9.
Comment #15
temoor commentedRe-rolled patch against latest dev version.
Comment #16
lwalley commentedRe-roll of #10 against 7.x-3.9.
Comment #17
lwalley commentedPatch upload fail, re-upload of #16 patch file and interdiff.