Show the last post subject to the index page of your forum
@13thoughts was looking for this on twitter. Basically this snippet adds the last post subject to the index page of your forums, but if the title is over a certain amount of characters, it gets trimmed (. . .) That way everything stays the same length and generally looks nicer
# #-----[ OPEN ]------------------------------------------ # includes/functions_display.php # #-----[ FIND ]------------------------------------------ #
$template->assign_block_vars('forumrow', array( 'S_IS_CAT' => false,
You can change the 28 to another number. Play about with it until it loks right for your forum
# #-----[ BEFORE ADD ]------------------------------------------ #
$char_limit = 28; $new_last_post_subject = (utf8_strlen(censor_text($last_post_subject)) > $char_limit + 5) ? (utf8_substr(censor_text($last_post_subject),0,$char_limit) . '...') : censor_text($last_post_subject);
# #-----[ FIND ]------------------------------------------ #
'LAST_POST_SUBJECT' => censor_text($last_post_subject),
# #-----[ AFTER ADD ]------------------------------------------ #
'NEW_LAST_POST_SUBJECT' => $new_last_post_subject,
# #-----[ FIND ]------------------------------------------ #
# #-----[ OPEN ]------------------------------------------ # styles/YOUR_STYLE/template/forumlist_body.html # #-----[ DIY INSTRUCTIONS ]------------------------------------------ #
You're going to want to add the following code in:
<!-- IF not S_IS_BOT --><a href="{forumrow.U_LAST_POST}">{forumrow.NEW_LAST_POST_SUBJECT}</a><!-- ELSE -->{forumrow.NEW_LAST_POST_SUBJECT}<!-- ENDIF -->
Somewhere around
<!-- IF forumrow.LAST_POST_TIME -->
As an example, here's what I did for a forum of mine:
# #-----[ FIND ]------------------------------------------ #
<!-- IF forumrow.LAST_POST_TIME --><dfn>{L_LAST_POST}</dfn> {L_POST_BY_AUTHOR} {forumrow.LAST_POSTER_FULL} <!-- IF not S_IS_BOT --><a href="{forumrow.U_LAST_POST}">{LAST_POST_IMG}</a> <!-- ENDIF --><br />{forumrow.LAST_POST_TIME}<!-- ELSE -->{L_NO_POSTS}<br /> <!-- ENDIF --></span>
# #-----[ REPLACE WITH ]------------------------------------------ #
<!-- IF forumrow.LAST_POST_TIME --><dfn>{L_LAST_POST}</dfn> <!-- IF not S_IS_BOT --><a href="{forumrow.U_LAST_POST}">{forumrow.NEW_LAST_POST_SUBJECT}</a><!-- ELSE -->{forumrow.NEW_LAST_POST_SUBJECT}<!-- ENDIF --> <br /> {L_POST_BY_AUTHOR} {forumrow.LAST_POSTER_FULL} <!-- IF not S_IS_BOT --><a href="{forumrow.U_LAST_POST}">{LAST_POST_IMG}</a> <!-- ENDIF --><br />{L_POSTED_ON_DATE} {forumrow.LAST_POST_TIME}<!-- ELSE -->{L_NO_POSTS}<!-- ENDIF --></span>