0

I'm attempting to change the values and add an additional array with some stripped down data to the Drupal views variables.

I've referenced the function in my template.php file, I am checking the results through <?php kpr( $variables ); ?> in views-view.tpl.php

The prog_search_vars array is not be created and the value for theme_hook_suggestions is not being changed either. Is there something I'm missing?

function views_vars(&$variables)
    {
        $view = $variables['view'];

        /* Applies only to my view */
        if($view->name == "myviewname")

        {


            /* Get data from views variables and strip down to string */
            $title = strip_tags($variables['fields']['title']->content);
            /* add data to array */
            $prog_search_vars['post_title'] = $title;

            $prgm_country = strip_tags( $variables['fields']['country']->content);
            $prog_search_vars['prgm_search_prgm_country'] = $prgm_country;


    /*Change existing key value */

            $variables['theme_hook_suggestions'][]='mytestvalue'; 

           /*Add my array */
            $variables['prog_search_vars'] = $prog_search_vars;

         };

     }

?>
  • What function/method calls views_vars (and how/when)? – Clive May 4 '18 at 18:10
  • it's in template.php – Sam May 5 '18 at 1:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.