Hi,
I have a view that has few fields one of them is called 'status' and another is from a relationship to flags called 'myflag'.
I want to change the myflag field to be "N/A" if the status field = 1.
I tried theming the views-view-field--myflag.tpl.php for the flag field, in this file i have a $row var which contains all the values of the fields in the row including the myflag and status...
... but Views seems to have some sort of name aliasing logic that I can't understand, so the prefix of the names of those fields may change according to filters I use (I have exposed filters in the view)
The: $data = $row->{$field->field_alias} returns "unknown" (usually it returns the name of the field im theming, but maybe the relationship throws it off?)
Is there a way to find the name of the 'status' field?
what i've done for now is a VERY ugly workaround.. I use get_object_vars($row) and search for a var that contains 'status' - it works... but i don't like it.
any ideas?
Thanks.
Comments
Use views custom field module
Hi ,
Its so simple use this module which will give ability to add a php code field inside views. If you face difficulty using this module please post here.
http://drupal.org/project/views_customfield
Cheers,
Anil Sagar,
Lead Drupal Developer,
Azri Soulutions,
http://azrisolutions.com/
Thanks, but it has the same behavior as theming
I tried your idea, and installed the module.
I added a php code field, but this field gives me a $data var which is identical to the $row var in the field theme page.
So, I still don't know the alias (prefix) to my status field (which changes according to the selected exposed filter).
Thank you.
Php code
Hi,
You need to write php code something like below in php code field.
Hope this helps..
Put my flag field above the php custom field and mark it as Exclude from display.
Cheers,
Anil Sagar,
Lead Drupal Developer,
Azri Soulutions,
http://azrisolutions.com/
thank you, but my problem is different
Maybe I'm not being clear:
I know I suppose to write php code, but my problem is that the name of the 'status' field changes according to the exposed filter used (or so it seems).
That is, it may be filter1_status for some cases and filter2_status for other cases (I guess it is some Views behavior I don't fully understand)
My problem is finding out the name of the 'status' field in the php code.
Thanks.