Closed (fixed)
Project:
Views (for Drupal 7)
Version:
5.x-1.6
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
3 Apr 2009 at 00:13 UTC
Updated:
3 Sep 2013 at 02:25 UTC
I know that I can modify a view and enter php snippets into the header and/or footer fields.
What I would like to know is if there is some hook_views which would allow my module to insert a php snippet into a view footer on the fly?
Comments
Comment #1
dawehnerthere is the hook:
hook_views_pre_render (&$view)
i think you can use it to solve your problem
Found at http://views.doc.logrus.com/
Comment #2
somebodysysop commentedThank you. This looks like it should do it. Just have to figure out how to modify the view footer.
Comment #3
dawehneryou could write a handbook or a blog entry if you managed to do it
by the way, you could also use hook_preprocess_...
Comment #4
merlinofchaos commentedIn prerender you could:
Note that the text will be run through check_markup using 'footer_format', so you may have to change that as well. (You can get original text via get_option).
THis function will check default display too so you don't have to worry about overrides.
Comment #5
somebodysysop commentedThank you! Haven't tried it yet, but I believe this is exactly what I was looking for.
Comment #6
somebodysysop commentedHere's the code I used:
Works like a charm! Again, thanks for the help.
Comment #7
junedkazi commentedI have also posted a write up of how to use the pre alter function for views.
The link is http://drupal.org/node/438370.
Pls do let me know if I have done anything wrong.
Comment #9
gauravary commentedHi,
I guess the hook "hook_views_pre_render()" only works for drupal 6. Is there any way to acomplish it for Drupal 5?
Thanks in advance!
Gaurav
Comment #10
gauravary commentedComment #11
dawehnerThere is hook_views_pre_view(&$view, &$items);fi
Comment #13
kenorb commented#6
Solution to: Views 3?
See: #749452: $view->display_handler->set_option('footer',$options) does not add footer in pre-render hook
Comment #14
jessehsNote that you can check to see which view and display you're modifying by the
$view->nameand$view->current_displayproperties of the view object. Without wrapping your custom logic in a conditional statement, you'd be modifying every view. Ex: