I needed to low-level customize the output of a View, with PHP. I have been playing around with hook_block_view_alter, with hook_views_pre_render, but the problem is that the exact field I was looking for did not appear in the last function and in block_view_alter I only had access to the content[#markup], which is the un-structured content. Is there some other function that I can use so I can have access to all content as in block_view_alter but only to change the value of a given field?
-
Hi, you should be able to change your field value in hook_views_pre_render. $view->results has it all. This may be helpful knackforge.com/blog/sivaji/…– Sujith NCommented Sep 14, 2015 at 9:10
-
Thanks. I finally found the fields that I needed. But my solution is so cumbersome that I doubt it is correct. I want to not display a field if another one has a value 0. I do not know how to do this just with the options available in the UI of Views. I finally used hook_views_pre_render to change the output for a value "-1", and then in hook_block_view_alter, change the -1 with an empty string. The -1 was shielded by especial chars [[-1]] to avoid problems in the replacement of the text.I find this solution so cumbersome that something must be wrong,may i can set a field visibility to false– CesarCommented Sep 14, 2015 at 9:15
Add a comment
|