Closed (fixed)
Project:
Views (for Drupal 7)
Version:
6.x-2.0-beta4
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
22 Apr 2008 at 21:09 UTC
Updated:
2 Jul 2008 at 15:32 UTC
I am trying to get a page view to show different information in the header depending on the arguments. How would I get the view args data via a php script in the header?
I would perfer not to use the args() function, as that seems too much of a hack, and would break if I ever use this view in a block.
Comments
Comment #1
merlinofchaos commentedOh crap, I didn't restore the global variable stuff from Views 1. I will put that back in, since the only way to get data to the PHP filter is via globals.
Comment #2
merlinofchaos commentedOk, finally checked this in -- views_set_current_view is now utilized during preview and execute_display; that should make it easy to use $view = views_get_current_view() during headers.
Comment #3
RoboPhred commentedRe-opening the support request, I am unable to use this:
The above code always prints false when set in the view header.
Comment #4
RoboPhred commentedI did some debugging. While the $cache variable in views_set_current_view is set properly when called, it fails "isset" on the second call from views_get_current_view.
It looks like something is clearing it, but it is only called twice: one for the set, and one for the get.
Comment #5
RoboPhred commentedI found the problem, it looks like the unset statement in views_set_current_view is removing the 'static' property of the variable.
The following code replacement works (line 3 commented out):
Of course, you have the warning about references, I don't really know if this will cause Untold Bad Things to happen.
PHP confirms this: http://us3.php.net/unset
Comment #6
merlinofchaos commentedOh well hopefully the static nature will also cause it not to overwrite references then.
Comment #7
merlinofchaos commentedOk, let's see if that does the trick.
Comment #8
RoboPhred commentedIt broke again...
You changed it to
which isn't working on my site.
I changed it back to
and it started working again.
PHP really doesn't like this area of the module...
Comment #9
merlinofchaos commentedBah! More reference pain. :/
Ah well. This will just have to have problems under PHP4, and that's all there is to it.
Comment #10
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #11
greg@beargroup.com commentedRunning into this on Beta4, running PHP 5.1
Have some themes that make decisions on the view id
This has no value
This returns true - but the print_r is empty
Thanks,
-Greg
Comment #12
merlinofchaos commentedIt looks like attachments could unset the view early. I checked in a fix to -dev.
Comment #13
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.