Issue #2329769 by lauriii, mortendk | davidhernandez: Move forum classes from preprocess to templates.
parent
3bb1ac5885
commit
a5d36eff66
|
@ -683,26 +683,24 @@ function template_preprocess_forum_icon(&$variables) {
|
||||||
$variables['hot_threshold'] = \Drupal::config('forum.settings')->get('topics.hot_threshold');
|
$variables['hot_threshold'] = \Drupal::config('forum.settings')->get('topics.hot_threshold');
|
||||||
|
|
||||||
if ($variables['num_posts'] > $variables['hot_threshold']) {
|
if ($variables['num_posts'] > $variables['hot_threshold']) {
|
||||||
$icon_status_class = $variables['new_posts'] ? 'hot-new' : 'hot';
|
$variables['icon_status'] = $variables['new_posts'] ? 'hot-new' : 'hot';
|
||||||
$variables['icon_title'] = $variables['new_posts'] ? t('Hot topic, new comments') : t('Hot topic');
|
$variables['icon_title'] = $variables['new_posts'] ? t('Hot topic, new comments') : t('Hot topic');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$icon_status_class = $variables['new_posts'] ? 'new' : 'default';
|
$variables['icon_status'] = $variables['new_posts'] ? 'new' : 'default';
|
||||||
$variables['icon_title'] = $variables['new_posts'] ? t('New comments') : t('Normal topic');
|
$variables['icon_title'] = $variables['new_posts'] ? t('New comments') : t('Normal topic');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($variables['comment_mode'] == CommentItemInterface::CLOSED || $variables['comment_mode'] == CommentItemInterface::HIDDEN) {
|
if ($variables['comment_mode'] == CommentItemInterface::CLOSED || $variables['comment_mode'] == CommentItemInterface::HIDDEN) {
|
||||||
$icon_status_class = 'closed';
|
$variables['icon_status'] = 'closed';
|
||||||
$variables['icon_title'] = t('Closed topic');
|
$variables['icon_title'] = t('Closed topic');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($variables['sticky'] == 1) {
|
if ($variables['sticky'] == 1) {
|
||||||
$icon_status_class = 'sticky';
|
$variables['icon_status'] = 'sticky';
|
||||||
$variables['icon_title'] = t('Sticky topic');
|
$variables['icon_title'] = t('Sticky topic');
|
||||||
}
|
}
|
||||||
|
|
||||||
$variables['attributes']['class'][] = 'icon';
|
|
||||||
$variables['attributes']['class'][] = 'topic-status-' . $icon_status_class;
|
|
||||||
$variables['attributes']['title'] = $variables['icon_title'];
|
$variables['attributes']['title'] = $variables['icon_title'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,13 +11,20 @@
|
||||||
* - icon_title: Text alternative for the forum icon, same as above.
|
* - icon_title: Text alternative for the forum icon, same as above.
|
||||||
* - new_posts: '1' when this topic contains new posts, otherwise '0'.
|
* - new_posts: '1' when this topic contains new posts, otherwise '0'.
|
||||||
* - first_new: '1' when this is the first topic with new posts, otherwise '0'.
|
* - first_new: '1' when this is the first topic with new posts, otherwise '0'.
|
||||||
|
* - icon_status: Indicates which status icon should be used.
|
||||||
*
|
*
|
||||||
* @see template_preprocess_forum_icon()
|
* @see template_preprocess_forum_icon()
|
||||||
*
|
*
|
||||||
* @ingroup themeable
|
* @ingroup themeable
|
||||||
*/
|
*/
|
||||||
#}
|
#}
|
||||||
<div{{ attributes }}>
|
{%
|
||||||
|
set classes = [
|
||||||
|
'icon',
|
||||||
|
'topic-status-' ~ icon_status,
|
||||||
|
]
|
||||||
|
%}
|
||||||
|
<div{{ attributes.addClass(classes) }}>
|
||||||
{% if first_new -%}
|
{% if first_new -%}
|
||||||
<a id="new"></a>
|
<a id="new"></a>
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
Loading…
Reference in New Issue