change views global text field conditionally

01/07/2018


I am trying to either show a text field or hide it depending on the date of another field in a view.
I am trying to use the views_pre_render hook and so far have:

function MODULE_NAME_views_pre_render(&$view) {
if ($view->name == 'user_dashboards' && $view->current_display == 'my_tutorials') 
{
    foreach ($view->result as $index => $value) 
    {
        $tutorialtime = strtotime($value->field_field_tr_tutorial_start[0]['raw']['value']);
        if($tutorialtime < strtotime('now'))
        {
            $view->field['nothing']->options['alter']['text'] = '';

        }   
    }   
}

}

So I can successfully test whether to show the field or not, however I can’t then change the field. Using the code above changes every global text field in the view. Is there a way to target just the row in the comparison?

قالب وردپرس