Search code examples
phpbbphpbb3

PHPBB3 - Can't get theme to display latest post title


I recently made my own PHPBB board and immediately found a theme, fell in love with it, and started customizing it. Well, shortly after launch, I realized the theme never displayed the post title under the "Last Post" column of the board. I did some digging, finding out I have to edit the the themes "viewforum_body.html" file in order to get it displaying, using different variables, namely "fourmrow.LAST_POST_SUBJECT".

Unfortunately, it seems that no matter where or how I plug it in, it won't work. For reference, I'm using the ProGlass theme, and here is the codeblock from "viewforum_body.html" that seems to deal with the "Last Post" column.

<!-- IF topicrow.S_FIRST_ROW or not topicrow.S_TOPIC_TYPE_SWITCH -->
    <div class="forumbg<!-- IF topicrow.S_TOPIC_TYPE_SWITCH and (topicrow.S_POST_ANNOUNCE or topicrow.S_POST_GLOBAL) --> announcement<!-- ENDIF -->">
    <div class="inner"><span class="corners-top"><span></span></span>
    <ul class="topiclist">
        <li class="header">
            <dl class="icon">
                <dt><!-- IF S_DISPLAY_ACTIVE -->{L_ACTIVE_TOPICS}<!-- ELSEIF topicrow.S_TOPIC_TYPE_SWITCH and (topicrow.S_POST_ANNOUNCE or topicrow.S_POST_GLOBAL) -->{L_ANNOUNCEMENTS}<!-- ELSE -->{L_TOPICS}<!-- ENDIF --></dt>
                <dd class="posts">{L_REPLIES}</dd>
                <dd class="views">{L_VIEWS}</dd>
                <dd class="lastpost"><span>{L_LAST_POST}</span></dd>
            </dl>
        </li>
    </ul>
    <ul class="topiclist topics">
<!-- ENDIF -->

    <li class="row<!-- IF topicrow.S_ROW_COUNT is even --> bg1<!-- ELSE --> bg2<!-- ENDIF --><!-- IF topicrow.S_POST_GLOBAL --> global-announce<!-- ENDIF --><!-- IF topicrow.S_POST_ANNOUNCE --> announce<!-- ENDIF --><!-- IF topicrow.S_POST_STICKY --> sticky<!-- ENDIF --><!-- IF topicrow.S_TOPIC_REPORTED --> reported<!-- ENDIF -->">
        <dl class="icon" style="background-image: url({topicrow.TOPIC_FOLDER_IMG_SRC}); background-repeat: no-repeat;">
            <dt<!-- IF topicrow.TOPIC_ICON_IMG and S_TOPIC_ICONS --> style="background-image: url({T_ICONS_PATH}{topicrow.TOPIC_ICON_IMG}); background-repeat: no-repeat;"<!-- ENDIF --> title="{topicrow.TOPIC_FOLDER_IMG_ALT}"><!-- IF topicrow.S_UNREAD_TOPIC --><a href="{topicrow.U_NEWEST_POST}">{NEWEST_POST_IMG}</a> <!-- ENDIF --><a href="{topicrow.U_VIEW_TOPIC}" class="topictitle">{topicrow.TOPIC_TITLE}</a>
                <!-- IF topicrow.S_TOPIC_UNAPPROVED or topicrow.S_POSTS_UNAPPROVED --><a href="{topicrow.U_MCP_QUEUE}">{topicrow.UNAPPROVED_IMG}</a> <!-- ENDIF -->
                <!-- IF topicrow.S_TOPIC_REPORTED --><a href="{topicrow.U_MCP_REPORT}">{REPORTED_IMG}</a><!-- ENDIF --><br />
                <!-- IF topicrow.PAGINATION --><strong class="pagination"><span>{topicrow.PAGINATION}</span></strong><!-- ENDIF -->
                <!-- IF topicrow.ATTACH_ICON_IMG -->{topicrow.ATTACH_ICON_IMG} <!-- ENDIF -->{L_POST_BY_AUTHOR} {topicrow.TOPIC_AUTHOR_FULL} &raquo; {topicrow.FIRST_POST_TIME}
            </dt>
            <dd class="posts">{topicrow.REPLIES} <dfn>{L_REPLIES}</dfn></dd>
            <dd class="views">{topicrow.VIEWS} <dfn>{L_VIEWS}</dfn></dd>
            <dd class="lastpost"><span><dfn>{L_LAST_POST}</dfn>{L_POST_BY_AUTHOR} {topicrow.LAST_POST_AUTHOR_FULL}
                <!-- IF not S_IS_BOT --><a href="{topicrow.U_LAST_POST}">{LAST_POST_IMG}</a> <!-- ENDIF --><br />{topicrow.LAST_POST_TIME}</span>
            </dd>
        </dl>
    </li>    

If anyone can help, I would greatly appreciate it.


Solution

  • ProGlass doesn't have its own forumlist_body.html file so you will need to edit that of ProSilver where it is inherited from. Don't do the edits via the ACP editor as the files will revert to standard state when you clear the cache. Download them, edit them in a proper text editor that can save the files as UTF8 without BOM, then upload the edited files using a proper FTP client - don't use your hosts file transfer as that can sometimes break the files.

    DON'T FORGET TO PURGE THE CACHE IN THE ACP AFTER MAKING ANY CHANGES!

    Taken from the phpBB dev wiki (https://www.phpbb.com/kb/article/adding-last-posts-subject-to-index/)...

    phpBB already includes a template variable to display the last post's subject on the index page, but it's not currently used. If a subject is greater than 10 or 15 characters, the subject could span 2 or more lines. This article will explain how to not only add the subject to index page, but shorten it if it is more than 10 characters long.

    First, open /includes/functions_display.php and find:

    'LAST_POST_SUBJECT'      => censor_text($last_post_subject),
    

    Replace that line with:

    'LAST_POST_SUBJECT'      => (utf8_strlen(censor_text($last_post_subject)) > 10) ? utf8_substr(censor_text($last_post_subject), 0, 10) . '...' : censor_text($last_post_subject),
    

    For prosilver based styles:

    Open /styles/prosilver/template/forumlist_body.html and find (note the code below is part of a larger line):

    <dfn>{L_LAST_POST}</dfn>
    

    On the same line right before the text above, add:

    {forumrow.LAST_POST_SUBJECT}<br />
    

    The whole line should look like this:

    <!-- IF forumrow.LAST_POST_TIME -->{forumrow.LAST_POST_SUBJECT}<br /><dfn>{L_LAST_POST}</dfn> {L_POST_BY_AUTHOR} {forumrow.LAST_POSTER_FULL}
    

    For subsilver2 based styles:

    Now, open /styles/subsilver2/template/forumlist_body.html and find

    <p class="topicdetails"><!-- IF forumrow.U_UNAPPROVED_TOPICS --><a href="{forumrow.U_UNAPPROVED_TOPICS}">{UNAPPROVED_IMG}</a>&nbsp;<!-- ENDIF -->{forumrow.LAST_POST_TIME}</p>
    

    On a new line before that line add

    <p class="topicdetails">{forumrow.LAST_POST_SUBJECT}</p>
    

    Now save all files and purge your cache.