Please can you help me figure out how to change the label (view table label) from code.

I am using domain access for a multisite, would like to use the same view on both site but the only issue i have is that the label of one column (field) has to change per site.

on site 1 : Label of field 1 = family
on site 2: Label of field 2 = group

They are both displaying the same data but the label has to change.

I will appreciate if you can help me figure out how i can implement that.

I have tried :
$view->display_handler->display->display_options['fields']['name']['label'] = 'group';
into hook_views_pre_render(&$view) and hook_views_pre_build(&$view)

with no luck.

Comments

ibakayoko’s picture

dawehner, helped me figured out the correct field to alter

$view->field['name']->options['label'] = 'group';
instead of $view->display_handler->display->display_options['fields']['name']['label'] = 'group';

i put that into hook_views_pre_render(&$view)

Thank you dawehner

MustangGB’s picture

Issue summary: View changes
Status: Active » Closed (outdated)