1

What I am doing wrong? The error says:

Fatal error: Call to a member function advanced_render() on a non-object in /var/www/mydrupalsite/themes/myTheme/template.php on line XXXX

/**
 * Overrides theme_views_view_field for a view
 *
 */
function myTheme_views_view_field($view, $field, $row) {
  //Work only for mobile view and section field
  if($view->name == 'mobile' && $field->options['label'] == 'Section') {
    $new_items = array();

    foreach($field->items as $skey => $subitem) {
      $new_items[$skey] = array();

      foreach($subitem as $key => $item) {
        $parent = taxonomy_get_parents($key);
        if(count($parent) == 0){
      //do not set item in items, if taxonomy does not have parent
        }
       else {
         $new_items[$skey][$key] = $item;
       }
      }
    }
  //Assign new items list to field items
    $field->items = $new_items;

    return $field->advanced_render($row);
  } else {
    return $field->advanced_render($row);
  }
}
1

I think you may have copied that code somewhat from a Drupal 6 version? The only problem is that the pattern for theme function signatures has changed in Drupal 7; only the $vars argument is passed in now, which is an array of named variables for the function:

function myTheme_views_view_field($vars) {
  $view = $vars['view'];
  $field = $vars['field'];
  $row = $vars['row'];

  // ...
}
  • Yeah Im in the process of upgrading Drupal 6 to 7 – ninjascorner Jun 25 '12 at 8:13

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.