Prepares variables for forums templates.
Default template: forums.html.twig.
array $variables: An array containing the following elements:
function template_preprocess_forums(&$variables) {
if ($variables['forums_defined'] = count($variables['forums']) || count($variables['parents'])) {
if (!empty($variables['forums'])) {
$variables['forums'] = array(
'#theme' => 'forum_list',
'#forums' => $variables['forums'],
'#parents' => $variables['parents'],
'#tid' => $variables['tid'],
);
}
else {
$variables['forums'] = array();
}
if ($variables['tid'] && array_search($variables['tid'], config('forum.settings')
->get('containers')) === FALSE) {
$variables['topics'] = array(
'#theme' => 'forum_topic_list',
'#tid' => $variables['tid'],
'#topics' => $variables['topics'],
'#sortby' => $variables['sortby'],
'#forum_per_page' => $variables['forum_per_page'],
);
}
else {
$variables['topics'] = array();
}
// Provide separate template suggestions based on what's being output. Topic id is also accounted for.
// Check both variables to be safe then the inverse. Forums with topic ID's take precedence.
if ($variables['forums'] && !$variables['topics']) {
$variables['theme_hook_suggestions'][] = 'forums__containers';
$variables['theme_hook_suggestions'][] = 'forums__' . $variables['tid'];
$variables['theme_hook_suggestions'][] = 'forums__containers__' . $variables['tid'];
}
elseif (!$variables['forums'] && $variables['topics']) {
$variables['theme_hook_suggestions'][] = 'forums__topics';
$variables['theme_hook_suggestions'][] = 'forums__' . $variables['tid'];
$variables['theme_hook_suggestions'][] = 'forums__topics__' . $variables['tid'];
}
else {
$variables['theme_hook_suggestions'][] = 'forums__' . $variables['tid'];
}
}
else {
$variables['forums'] = array();
$variables['topics'] = array();
}
}