function views_preprocess_comment

Same name in other branches
  1. 9 core/modules/views/views.module \views_preprocess_comment()
  2. 10 core/modules/views/views.module \views_preprocess_comment()
  3. 11.x core/modules/views/views.module \views_preprocess_comment()

A theme preprocess function to automatically allow view-based node templates if called from a view.

File

core/modules/views/views.module, line 269

Code

function views_preprocess_comment(&$variables) {
    // The view data is added to the comment in
    // \Drupal\views\Plugin\views\row\EntityRow::preRender().
    if (!empty($variables['comment']->view) && $variables['comment']->view->storage
        ->id()) {
        $variables['view'] = $variables['comment']->view;
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.