Closed (works as designed)
Project:
Views PHP
Version:
7.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
21 Jul 2015 at 12:31 UTC
Updated:
12 Nov 2015 at 18:33 UTC
Jump to comment: Most recent
Comments
Comment #1
Sawascwoolf commentedI'm facing the same problem.
I could imagine this has something to do with using a relationship in this particular view.
Can you confirm this?
Comment #2
joegl commentedHaving the same issue. In the "Value Code" section I:
and then in the "Output Code" section I:
I trace down the field data I want and return a value from the $data object in the "Value Code" section:
And then in the "Output Code" section I:
The $value is always blank and nothing is outputted. No matter what value I pick from the $data object in the "Value Code" section it's always blank.
Accessing the $data object in the "Output Code" section works fine. However, I need it set in the "Value Code" section so I can use it in a Global: PHP Sort Criteria.
I am also aware of the issue with $row object values containing the NID instead of the actual data, but usually I'm able to bypass it with the $data object. Apparently this only works in the "Output Code" and not "Value Code". Does anyone know a workaround?
Comment #3
joegl commentedI used a workaround for now but I don't like it. I am pulling users so I use the $data->uid and user_load functions to get the user's correct data in the "Value Code" section. E.g.,
From there you can trace the data in the "Output Code" section by doing a:
Once you've traced your field you can then set it like so in the "Value Code" section:
I am not sure if this is adding extra queries to the database or if it's all aggregated by views (I assume it's not aggregated because it's raw PHP but I don't know the inner workings of this module). I don't like the idea of extra database hits but it's the best I could do.
This works for the PHP sort now because the value is being set in the "Value Code" section.
For those of you working on nodes, you would instead use:
Cheers! This is a great module.
Comment #4
fizk commented$staticpersists across rows, so doing something like$static = $row->nidin the Value code section will be overwritten by each row, leaving you with$statichaving the value of the last row. Thus, printing$staticin the Output code section shows the same value for every row.Comment #5
joegl commentedCould you be more descriptive? I am not sure how your comment addresses this exact issue?