Posted by mikeytown2 on October 28, 2009 at 7:37am
| Project: | DraggableViews |
| Version: | 6.x-3.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
Issue Summary
Looking at how to hook into the save button and get the view. Any tips?
#616608: Expire view after draggable view operation
Comments
#1
This would require a new hook. Do you still need this? Why would you need this?
#2
#3
I would like to have this for cache expiration inside the boost module. This way when the draggable view is changed and saved I can flush the other related views pages from the cache so changes show up for logged out users instantly.
#4
I would like if the was a draggbleview option to clear view's cache on save
till then
<?php
/**
* Implementation of hook_form_alter().
*/
function mymodule_form_alter(&$form, $form_state, $form_id) {
if (strpos($form_id, 'draggableviews_view_draggabletable_form') === 0) {
$form['#submit'][] = 'mymodule_draggable_views_drop_cache';
}
}
function mymodule_draggable_views_drop_cache($form, &$form_state) {
$name = $form['#parameters'][1]->view->name;
// clear relevant caches
}
?>
At the least, it'd be nice if the form saved the view at $form['#view'] or such instead of checking parameters.
#5
I think this is needed so anonymous users will see the reordered view.
I just tested with 2 browsers, and the anon user didn't get the new order.
After "Clear Cache" it worked.
Cache mode is set to "normal"
#6
Also just discovered this issue; the page cache should optionally be invalidated after a draggable view has been reordered and saved. It would be ideal if we could discover (or specify) which paths to invalidate, but this seems pretty complicated, so perhaps just clearing everything will suffice.
Retitling and setting back to "active", because there is no patch to review.
#7
Patch attached that adds a "Clear page cache after saving" checkbox to the Draggable Table style plugin settings. If this is checked, the page cache will be invalidated after reordering a view, so anonymous users will see changes more quickly (at least after the minimum cache expiration time).
#8
I suggest to use a combination of modules, avoiding patches.
Lets suppose we have a View with 2 displays: Page1 is for display ordered nodes to users, Page2 is for order your nodes using a Draggableview table.
1) Create the View said before using Draggableviews module.
2) Install Rules module and Rules Forms support module, that comes with it.
3) Install Cache Actions module.
4) In Page1 views configuration, set the cache to "Rules-triggered cache".
5) Follow instruction for Rules Forms support (read README.TXT, in module's folder) to enable event activation on Page2 ordering form.
6) Create a rule that can be triggered on your Page2 ordering form submit.
7) In that rule, set the action "Clear the cache for views displays" and select Page1 display. You can select also different actions, like empty the whole view cache or th Varnish cache (if you need).
8) Go to Page2 order page, change the order of your nodes and save the new sorting.
9) Done!
#9
I vote for Rules approach too... but for D7 the rules form support doesn't exists.
Please take a look at my patch #1316806: Add rules support (at least the event 'on sort') for the event part
#10
Asked for a 6.x backport of the patch in #1316806: Add rules support (at least the event 'on sort').
For now, the workaround by kongoji in #8 works perfectly for me.