Add last replied topic to the forums listing.
This commit is contained in:
parent
feb1ecf530
commit
14424687d6
5 changed files with 175 additions and 27 deletions
|
@ -11,7 +11,8 @@
|
|||
|
||||
&__entry {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
align-items: stretch;
|
||||
min-height: 50px;
|
||||
|
||||
&:not(:last-child) {
|
||||
border-bottom: 1px solid #9475b2;
|
||||
|
@ -22,25 +23,32 @@
|
|||
&__icon {
|
||||
flex-shrink: 0;
|
||||
flex-grow: 0;
|
||||
align-self: flex-start;
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
&__info {
|
||||
flex-grow: 1;
|
||||
flex-shrink: 1;
|
||||
padding-left: 6px;
|
||||
padding-left: 4px;
|
||||
display: inline-flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
&__title {
|
||||
font-size: 1.2em;
|
||||
line-height: 1.5em;
|
||||
color: #306;
|
||||
|
||||
&__link {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&__description,
|
||||
&__subforums {
|
||||
|
@ -59,8 +67,9 @@
|
|||
|
||||
&__stats {
|
||||
text-align: center;
|
||||
flex-grow: 0;
|
||||
flex-shrink: 0;
|
||||
justify-content: center;
|
||||
min-width: 100px;
|
||||
flex-direction: column;
|
||||
|
||||
@media (max-width: @mio-forum-listing-mobile) {
|
||||
display: none;
|
||||
|
@ -78,15 +87,70 @@
|
|||
}
|
||||
|
||||
&__activity {
|
||||
flex-grow: 0;
|
||||
flex-shrink: 0;
|
||||
text-align: right;
|
||||
margin: 0 10px;
|
||||
width: 220px;
|
||||
min-width: 270px;
|
||||
align-items: center;
|
||||
|
||||
@media (max-width: @mio-forum-listing-mobile) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
&__title {
|
||||
line-height: 1.4em;
|
||||
margin-bottom: 2px;
|
||||
|
||||
&__link {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
&--unread {
|
||||
font-weight: 700;
|
||||
}
|
||||
}
|
||||
|
||||
&__info {
|
||||
font-size: .9em;
|
||||
line-height: 1.2em;
|
||||
}
|
||||
|
||||
&__user {
|
||||
font-weight: 700;
|
||||
text-decoration: none;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
&__avatar {
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
margin-right: 3px;
|
||||
flex-grow: 0;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
&__none,
|
||||
&__details {
|
||||
margin-left: 5px;
|
||||
flex-grow: 1;
|
||||
flex-shrink: 1;
|
||||
}
|
||||
}
|
||||
|
||||
&__stats,
|
||||
&__activity {
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
flex-grow: 0;
|
||||
border-left: 1px solid #9475b2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,6 @@
|
|||
line-height: 1.2em;
|
||||
|
||||
&__name {
|
||||
color: inherit;
|
||||
font-weight: 700;
|
||||
text-decoration: none;
|
||||
|
||||
|
@ -74,7 +73,6 @@
|
|||
|
||||
&__stat {
|
||||
line-height: 1.2em;
|
||||
min-width: 70px;
|
||||
|
||||
&--posts {
|
||||
font-size: 1.3em;
|
||||
|
@ -90,6 +88,7 @@
|
|||
&__stats {
|
||||
text-align: center;
|
||||
padding-left: 1px;
|
||||
min-width: 70px;
|
||||
}
|
||||
|
||||
&__activity {
|
||||
|
|
|
@ -92,7 +92,13 @@ if ($forum['forum_type'] == 0) {
|
|||
|
||||
$getSubforums = $db->prepare('
|
||||
SELECT
|
||||
`forum_id`, `forum_name`, `forum_description`, `forum_type`, `forum_link`,
|
||||
f.`forum_id`, f.`forum_name`, f.`forum_description`, f.`forum_type`, f.`forum_link`,
|
||||
t.`topic_id` as `recent_topic_id`, p.`post_id` as `recent_post_id`,
|
||||
t.`topic_title` as `recent_topic_title`,
|
||||
p.`post_created` as `recent_post_created`,
|
||||
u.`user_id` as `recent_post_user_id`,
|
||||
u.`username` as `recent_post_username`,
|
||||
COALESCE(r.`role_colour`, CAST(0x40000000 AS UNSIGNED)) as `recent_post_user_colour`,
|
||||
(
|
||||
SELECT COUNT(t.`topic_id`)
|
||||
FROM `msz_forum_topics` as t
|
||||
|
@ -104,6 +110,27 @@ $getSubforums = $db->prepare('
|
|||
WHERE p.`forum_id` = f.`forum_id`
|
||||
) as `forum_post_count`
|
||||
FROM `msz_forum_categories` as f
|
||||
LEFT JOIN `msz_forum_topics` as t
|
||||
ON t.`topic_id` = (
|
||||
SELECT `topic_id`
|
||||
FROM `msz_forum_topics`
|
||||
WHERE `forum_id` = f.`forum_id`
|
||||
AND `topic_deleted` IS NULL
|
||||
ORDER BY `topic_bumped` DESC
|
||||
LIMIT 1
|
||||
)
|
||||
LEFT JOIN `msz_forum_posts` as p
|
||||
ON p.`post_id` = (
|
||||
SELECT `post_id`
|
||||
FROM `msz_forum_posts`
|
||||
WHERE `topic_id` = t.`topic_id`
|
||||
ORDER BY `post_id` DESC
|
||||
LIMIT 1
|
||||
)
|
||||
LEFT JOIN `msz_users` as u
|
||||
ON u.`user_id` = p.`user_id`
|
||||
LEFT JOIN `msz_roles` as r
|
||||
ON r.`role_id` = u.`display_role`
|
||||
WHERE `forum_parent` = :forum_id
|
||||
AND `forum_hidden` = false
|
||||
');
|
||||
|
|
|
@ -17,7 +17,6 @@ $categories = $db->query('
|
|||
WHERE f.`forum_parent` = 0
|
||||
AND f.`forum_type` = 1
|
||||
AND f.`forum_hidden` = false
|
||||
GROUP BY f.`forum_id`
|
||||
ORDER BY f.`forum_order`
|
||||
')->fetchAll();
|
||||
|
||||
|
@ -33,17 +32,44 @@ $categories = array_merge([
|
|||
$getSubCategories = $db->prepare('
|
||||
SELECT
|
||||
f.`forum_id`, f.`forum_name`, f.`forum_description`, f.`forum_type`, f.`forum_link`,
|
||||
t.`topic_id` as `recent_topic_id`, p.`post_id` as `recent_post_id`,
|
||||
t.`topic_title` as `recent_topic_title`,
|
||||
p.`post_created` as `recent_post_created`,
|
||||
u.`user_id` as `recent_post_user_id`,
|
||||
u.`username` as `recent_post_username`,
|
||||
COALESCE(r.`role_colour`, CAST(0x40000000 AS UNSIGNED)) as `recent_post_user_colour`,
|
||||
(
|
||||
SELECT COUNT(t.`topic_id`)
|
||||
FROM `msz_forum_topics` as t
|
||||
WHERE t.`forum_id` = f.`forum_id`
|
||||
SELECT COUNT(`topic_id`)
|
||||
FROM `msz_forum_topics`
|
||||
WHERE `forum_id` = f.`forum_id`
|
||||
) as `forum_topic_count`,
|
||||
(
|
||||
SELECT COUNT(p.`post_id`)
|
||||
FROM `msz_forum_posts` as p
|
||||
WHERE p.`forum_id` = f.`forum_id`
|
||||
SELECT COUNT(`post_id`)
|
||||
FROM `msz_forum_posts`
|
||||
WHERE `forum_id` = f.`forum_id`
|
||||
) as `forum_post_count`
|
||||
FROM `msz_forum_categories` as f
|
||||
LEFT JOIN `msz_forum_topics` as t
|
||||
ON t.`topic_id` = (
|
||||
SELECT `topic_id`
|
||||
FROM `msz_forum_topics`
|
||||
WHERE `forum_id` = f.`forum_id`
|
||||
AND `topic_deleted` IS NULL
|
||||
ORDER BY `topic_bumped` DESC
|
||||
LIMIT 1
|
||||
)
|
||||
LEFT JOIN `msz_forum_posts` as p
|
||||
ON p.`post_id` = (
|
||||
SELECT `post_id`
|
||||
FROM `msz_forum_posts`
|
||||
WHERE `topic_id` = t.`topic_id`
|
||||
ORDER BY `post_id` DESC
|
||||
LIMIT 1
|
||||
)
|
||||
LEFT JOIN `msz_users` as u
|
||||
ON u.`user_id` = p.`user_id`
|
||||
LEFT JOIN `msz_roles` as r
|
||||
ON r.`role_id` = u.`display_role`
|
||||
WHERE f.`forum_parent` = :forum_id
|
||||
AND f.`forum_hidden` = false
|
||||
AND ((f.`forum_parent` = 0 AND f.`forum_type` != 1) OR f.`forum_parent` != 0)
|
||||
|
|
|
@ -46,10 +46,14 @@
|
|||
<img src="{{ forum_icon|format(forum_type, forum_read) }}" alt="read" class="forum__listing__entry__icon">
|
||||
|
||||
<div class="forum__listing__entry__info">
|
||||
<a href="/forum/forum.php?f={{ forum.forum_id }}" class="forum__listing__entry__title">{{ forum.forum_name }}</a>
|
||||
<div class="forum__listing__entry__title">
|
||||
<a href="/forum/forum.php?f={{ forum.forum_id }}" class="forum__listing__entry__title__link">{{ forum.forum_name }}</a>
|
||||
</div>
|
||||
|
||||
<div class="forum__listing__entry__description">
|
||||
{{ forum.forum_description|nl2br }}
|
||||
</div>
|
||||
|
||||
{% if forum.forum_subforums is defined and forum.forum_subforums|length > 0 %}
|
||||
<div class="forum__listing__entry__subforums">
|
||||
{% for subforum in forum.forum_subforums %}
|
||||
|
@ -65,9 +69,37 @@
|
|||
</div>
|
||||
|
||||
<div class="forum__listing__entry__activity">
|
||||
{% if forum.recent_topic_id is null %}
|
||||
<div class="forum__listing__entry__activity__none">
|
||||
There are no posts in this forum yet.
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="forum__listing__entry__activity__details">
|
||||
<div class="forum__listing__entry__activity__title">
|
||||
<a class="forum__listing__entry__activity__title__link"
|
||||
href="/forum/topic.php?p={{ forum.recent_post_id }}#p{{ forum.recent_post_id }}">
|
||||
{{ forum.recent_topic_title|slice(0, 30) ~ (forum.recent_topic_title|length > 30 ? '...' : '') }}
|
||||
</a>
|
||||
</div>
|
||||
<div class="forum__listing__entry__activity__info">
|
||||
{% if forum.recent_post_user_id is not null %}
|
||||
by <a
|
||||
href="/profile.php?u={{ forum.recent_post_user_id }}"
|
||||
style="color:{{ forum.recent_post_user_colour|colour_get_css }}"
|
||||
class="forum__listing__entry__activity__user">{{ forum.recent_post_username }}</a>,
|
||||
{% endif %}
|
||||
{{ forum.recent_post_created }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if forum.recent_post_user_id is not null %}
|
||||
<a
|
||||
href="/profile.php?u={{ forum.recent_post_user_id }}"
|
||||
class="avatar forum__listing__entry__activity__avatar"
|
||||
style="background-image:url('/profile.php?u={{ forum.recent_post_user_id }}&m=avatar')">
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
|
Loading…
Add table
Reference in a new issue