Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.7.2, 2.8
-
MOODLE_27_STABLE, MOODLE_28_STABLE
-
MOODLE_29_STABLE
-
MDL-48822-master -
Description
During setting custom styling to the forum, I found out that I could really use an indicator for the last post in a discussion. Not the chronologically last post but the last one to be displayed.
I came up with this code that I added at the end of forum_get_all_discussion_posts() after the $posts array has been rearranged.
$lastpost = false; |
// start with the last child of the first post
|
$post = &$posts[reset($posts)->id]; |
while (!$lastpost) { |
if (!isset($post->children)) { |
$post->lastpost = true; |
$lastpost = true; |
}
|
else // go to the last child of this post |
$post = &$posts[end($post->children)->id]; |
}
|
Later on, when building the HTML, if isset($post->lastpost) is true I add the "lastpost" class (same syntax as "firstpost" that's already in the code).
This improvement is purely for the benefit of the front-end output and I believe it will come in handy when working with styling and script writing.
Attachments
Issue Links
- caused a regression
-
MDL-50152 Last post in a forum thread is not hilighted as unread
-
- Closed
-