Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In our use case we need to know the filter that was set on the view in order to do more processing in a PHP type field. This patch adds the $view object to the eval so that information about the view can be access.
If you care, after applying this patch the view's filter can be access in $view->exposed_data
Comment | File | Size | Author |
---|---|---|---|
views_customfield_add_view_data_to_php_eval.patch | 1.79 KB | harking |
Comments
Comment #1
DarrellDuane CreditAttribution: DarrellDuane commentedThis is a huge help! thanks harking
I use $view->args to get the argument to the view
and $view->result to get access to other rows' data for doing comparisions/calculations. Thanks for this patch.
It works well for me.
Comment #2
syakely CreditAttribution: syakely commentedBig Help, exactly what I needed.
One suggestion to the patch. Add in
.t('$view: contains the $view data (e.g. $view->exposed_data).')
to the function options_form(&$form, &$form_state).
Thanks!!
Comment #3
skylord CreditAttribution: skylord commentedPatch works OK! Plz, commit it to the main branch....
Comment #4
DarrellDuane CreditAttribution: DarrellDuane commentedgreat idea syakely! Lets get this in the main branch!
Comment #5
jstollerI'm not entirely sure this patch is necessary. It doesn't seem to be well documented, but you should be able to access the view object in your custom field in $this->view
Comment #6
casey CreditAttribution: casey commentedI added this to the D7 version: http://drupal.org/project/views_php
Please help me test it.
Comment #7
YK85 CreditAttribution: YK85 commentedsubscribing