I have a (Apache solr) view with a Global: Custom text
field in addition to my normal fields. This field is meant to get value from a custom function/existing field/passing an existing field to a custom function and using return value in one of my modules per each result and I am trying to accomplish this functionality without using Views PHP module.
I referred this very similar query and tried the following approach which did not yield me the result:
function mymod_views_pre_render(&$view) {
if ($view->name == 'mymodview' && $view->current_display == 'mymod_display') {
$result = &$view->result;
foreach ($result as $num_idx => $result_obj) {
$result[$num_idx]->nothing = $result_obj->an_already_available_field_or_fxn_call;
}
}
}
Also tried the same code with hook_views_post_execute
to no avail. Using $view->field['nothing']->options['alter']['text'] = 'My custom text';
set the default text value to all fields which was not my desired result.
Based on the post linked earlier tried the following code in my theme's template.php
template_preprocess_views_view_fields
:
function mytheme_preprocess_views_view_fields(&$vars) {
$view = $vars['view'];
if ($view->name != 'mymodview' && $view->current_display != 'mymod_display') {
return;
}
foreach ($view->field as $id => $field) {
$vars['fields']['nothing']->content = 'Some global custom text content';
}
}
I am unable to determine what I am missing out on owing to my relative inexperience with views functionality and guidance on achieving this programatically would be much appreciated.