(sorry for my english)
How can I output calculated fields based on other real table fields?
For example: I have table "user_stats" with fields "uploaded" and "downloaded" and I want to output also a "ratio" calculated field (which will be = uploaded / downloaded).
I could use "Global: Custom text" field with it's patterns, but it doesn't support PHP code in itself...
Should I create special "views_field_hook" which will support PHP code or is there other better solution?
Will it be solved in 6.x - 3.x - version?
Thanx.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | views_handler_field_php.inc_.zip | 2.16 KB | liquixis |
Comments
Comment #1
dawehneras fast solution you can use theming of global: custom text, and get the values from the other fields.
Comment #2
liquixis commentedI implemented own "views_handler_field": "views_handler_field_php"
P.S. There is a typo in my first post: not "views_field_hook", but "views_handler_field".
Comment #3
liquixis commentedComment #4
pixelantegroup commentedCool solution!
Would I be able to use this solution as a grouping field in a view?
I tried using the Global: Custom Text field, but it seems as if the value is not calculated at the time the grouping is performed, so it was a no go.
Comment #5
liquixis commentedThanks.
Yes, you can use this solution as grouping field in a view (I tested it with "Style: Table" "Grouping field").
I tried to group with "Global: Custom Text", but as you said, it doesn't work...
P.S. I'll post updated version soon (with some improvements).
Comment #6
merlinofchaos commentedI don't think I want a PHP field in Views itself. I recommend turning this into a module. It should require minimal maintenance, I would think, and would make it available as an addon for people who need it but would not be there for people who do not. Just be very careful with permissions so you don't open security holes.
Comment #7
kvvnn commentedPlease excuse my ignorance, but this adds an additional field to Views? What is it grouped under, and what is its name?
Comment #8
kvvnn commentedAnyone interested in having a PHP field in Views should use this module : www.drupal.org/project/views_customfield