Login  Register

How to add the post title to the Last Post column with NAML

Posted by mark on Jan 05, 2020; 5:43am
URL: https://support.nabble.com/How-to-add-the-post-title-to-the-Last-Post-column-with-NAML-tp7604802.html

This isn't a question (just a how-to sort of thing). Feel free to offer improvements. This changes the last post contents both for forums and for threads (so that it shows the subject and the date instead of just the date). I'm not sure how to make it do it just for the last posts within forums (as opposed to also the last reply in a topic). There may or may not be other issues with this.

Here's a way to do it on n8.nabble.com

Create a new macro called smart_post_link_last_post.

Put the following code in it:
<macro name="smart_post_link_last_post" requires="node" dot_parameter="href" parameters="text, title, class">
    <n.if.is_post>
        <then>
            <a href="[n.node_href.href/]" title="[n.title/]" class="[n.hide_null.class/] post-link[n.topic_node.id/]" node-id="[n.id/]"><n.node_text.text/> ~ <n.node_text.title/></a>
            <n.call_later value="[n.topic_node.id/]" param="markUnreadTopics"/>
        </then>
        <else.node_link text="[n.title/]"/>
    </n.if.is_post>
</macro>

Edit the macro called last_post_column and change the references to smart_post_link to smart_post_link_last_topic. The reason we don't just override smart_post_link is because it's used in other contexts.

To keep it from making the Topics column tiny when viewing forums with no sub-forums on a mobile device, go to the standard_table_columns macro and topics_table_columns (as well as others depending on which types of apps your forum uses), and change

<n.last_post_column white_space="nowrap">

to

<n.last_post_column white_space="wrap">

If you find two macros with that name, I believe you can change it to wrap in both.

If you just want the category pages to have the topic show up for the last post, then add another parameter to last_post_column, pass something into it from view_category_page and in last_post_column, check to see if that parameter is not null, and use smart_post_link_last_post only when it's not null.