Is there a way to react on changes of views?

My problem:
DraggableViews module needs to register a theme for each View and display (because it wraps a form around the view output).
When a view gets saved a cache_clear_all is performed, but the theme_registry stays unaffected.

I would also need to remove some entries from the database when a view gets deleted.

A hook_viewsapi similar to hook_nodeapi would be great.

Thank,
sevi

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

esmerel’s picture

Assigned: Unassigned » dawehner

dereine - is this maybe in 3.x? If not, postpone it and unassign it :D

dawehner’s picture

Status: Active » Needs review
FileSize
680 bytes

It's not in 3.x but here is a patch

bojanz’s picture

Version: 6.x-2.x-dev » 6.x-3.x-dev

I like the idea.
However, would like to see some advanced help documentation on this (which I can provide)

dawehner’s picture

FileSize
2.34 KB

Allow views_save/delete to alter the view. Also added some documentation and docs/docs.php

dawehner’s picture

Assigned: dawehner » Unassigned
merlinofchaos’s picture

One question: Have you considered how this will play with exported views? Exports are one of the reasons I have resisted adding these hooks.

merlinofchaos’s picture

Status: Needs review » Closed (won't fix)

Yeah. No answer and I think it's because it's unanswerable. These hooks won't work due to exporting. I realize it's a pain in the butt, but that's the way it is.

heylookalive’s picture

Issue summary: View changes
Status: Closed (won't fix) » Active

Hi, was wondering if over the course of a few years that anything has come up that would make this more possible?

geek-merlin’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Priority: Normal » Major

Hmm, if i get it right, this is still not possible in 7.x.
Daring to raise prio.
Did not check 8.x (core) yet.

geek-merlin’s picture

Title: hook_views_save, hook_views_edit, hook_view_delete » Provide hook_views_save, hook_view_delete

Hmm, code is straightforward, should be trivial to port.

geek-merlin’s picture

Status: Active » Needs review
FileSize
2.3 KB

Trivial patch flying in that fixes this issue for me.
I need this for an upcoming contrib module and tested it worksforme.
Merlins #7 is no longer an issue in D7, i tested that a feature revert triggers the delete hook.

Pol’s picture

I'm also willing to have those hooks.

dawehner’s picture

Status: Needs review » Fixed

Committed this to views 7.x-3.x
One reason why this makes sense is that this adds some more symmetry between Views 7 and Views 8.

  • dawehner committed 6e352ed on 7.x-3.x authored by axel.rutz
    Issue #551808 by dawehner, axel.rutz: Provide hook_views_save,...
Pol’s picture

And 1:31 later it was fixed!

Thanks Daniel !!!!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.