Skip to content

Instantly share code, notes, and snippets.

Created March 18, 2017 17:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5f204bf020fac1c34b0dc85daa076423 to your computer and use it in GitHub Desktop.
Save anonymous/5f204bf020fac1c34b0dc85daa076423 to your computer and use it in GitHub Desktop.
function mytheme_preprocess_user(&$variables) {
if($variables['elements']['#view_mode'] == 'full') {
/** @var $target_user \Drupal\user\Entity\User */
$target_user = $variables['user'];
$supported_projects_by_user_view = \Drupal\views\Views::getView('supported_projects_by_enlightaid_user');
$supported_projects_by_user_view->get_total_rows = TRUE;
$supported_projects_by_user_view->execute('supported_projects_by_user_block');
$variables['projects_supported'] = $supported_projects_by_user_view->render();
$variables['num_projects_supported'] = $supported_projects_by_user_view->total_rows;
/**
* Now in user--full.html.twig
* {{projects_supported}} renders the view
* {{num_projects_supported}} is the total result of view
*/
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment