1

I created a simple view, it has 4 item (node) with 3 field (title, image, custom field). The image, title and field_promote are null.

I tried this:

function theme_preprocess_views_view__customview(&$variables) {
   $rows = $variables['rows'];

   foreach ($rows[0]['#rows'] as $id => $row) {

        $variables['rows'][$id] = array();
        $variables['rows'][$id]['image'] = $row['#view']->field['image'];
        $variables['rows'][$id]['title'] = $row['#view']->field['title'];
        $variables['rows'][$id]['attributes'] = array();

        $variables['pager'][$id] = array();
        $variables['pager'][$id]['id'] = $id;
        $variables['pager'][$id]['content'] = $row['#view']->field['promote_title'];
    }
}
  • First of all, are you sure that your preprocess function was called? By default, drupal only calls THEME_preprocess_views_view_'display_style'. – Vagner Feb 29 '16 at 0:38
  • Yes, I dumped some vars in this function and it worked. – vencel Feb 29 '16 at 20:21

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.