On this page
function template_preprocess_forum_submitted
template_preprocess_forum_submitted(&$variables)
Prepares variables for forum submission information templates.
The submission information will be displayed in the forum list and topic list.
Default template: forum-submitted.html.twig.
Parameters
array $variables: An array containing the following elements:
- topic: The topic object.
File
- core/modules/forum/forum.module, line 634
- Provides discussion forums.
Code
function template_preprocess_forum_submitted(&$variables) {
$variables['author'] = '';
if (isset($variables['topic']->uid)) {
$username = array('#theme' => 'username', '#account' => User::load($variables['topic']->uid));
$variables['author'] = drupal_render($username);
}
$variables['time'] = isset($variables['topic']->created) ? \Drupal::service('date.formatter')->formatTimeDiffSince($variables['topic']->created) : '';
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!forum!forum.module/function/template_preprocess_forum_submitted/8.1.x