• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Add forum title to thread list of a master forum

#1
I have created a master forum (threads from several forums aggregated into a master forum thread list).

On the second line, before the thread starter's username, I would like to add the title of the forum that the thread is from.

I'm digging into thread_list code (see below), and I've found where I need to edit. However, I'm not sure exactly how to call the forum title of the thread.

Any suggestions?

Thank You.

PHP:
<div class="secondRow">
                <div class="posterDate muted">
                    <xen:username user="$thread" title="{xen:phrase thread_starter}" />,
                    <a{xen:if {$visitor.user_id}, ' href="{xen:link threads, $thread}"'} class="faint"><xen:datetime time="$thread.post_date" title="{xen:if {$visitor.user_id}, '{xen:phrase go_to_first_message_in_thread}'}" /></a><xen:if is="{$showForumLink}">,
                    <a href="{xen:link forums, $thread.forum}" class="forumLink">{$thread.forum.title}</a></xen:if>

                    <xen:if is="{$showLastPageNumbers} AND {$thread.lastPageNumbers}">
                        <span class="itemPageNav">
                            <span>...</span>
                            <xen:foreach loop="$thread.lastPageNumbers" value="$pageNumber">
                                <a href="{xen:link threads, $thread, 'page={$pageNumber}'}">{$pageNumber}</a>
                            </xen:foreach>
                        </span>
                    </xen:if>
                </div>
 

Jake Bunce

XenForo moderator
Staff member
#2
There is already a flag for this. Example:

Admin CP -> Appearance -> Templates -> find_new_threads

Code:
			<xen:include template="thread_list_item">
				<xen:set var="$showForumLink">1</xen:set>
				<xen:set var="$showLastPageNumbers">1</xen:set>
			</xen:include>
You need to set $showForumLink when including thread_list_item. This would normally be in the content template of the page:

http://xenforo.com/community/threads/1-0-0-b1-how-to-identify-the-root-template-of-a-page.5591/
 
#3
There is already a flag for this. Example:

Admin CP -> Appearance -> Templates -> find_new_threads

Code:
<xen:include template="thread_list_item">
<xen:set var="$showForumLink">1</xen:set>
<xen:set var="$showLastPageNumbers">1</xen:set>
</xen:include>
You need to set $showForumLink when including thread_list_item. This would normally be in the content template of the page:

http://xenforo.com/community/threads/1-0-0-b1-how-to-identify-the-root-template-of-a-page.5591/
Thank you! Let me see if I have this right...

Goto the content template of that page. Add the code that is pasted above. Done?

Sorry... I know some php, but not enough to follow what you wrote above. My apologies, and thank you for your time.
 

Jake Bunce

XenForo moderator
Staff member
#4
Add the code that is pasted above. Done?
Find the code that includes thread_list_item and modify it to set that flag appropriately. It's not necessarily copy/paste. And I am assuming that your "master" forum is an addon that uses the thread_list_item template.
 
#5
Okay...

Found the code in the thread_list template that includes the thread_list_item template. I added the <xen:set var="$showForumLink">1</xen:set> (see below) to no effect. I will keep trying and let you know. Thank you for your help.

PHP:
<xen:include template="ad_thread_list_below_stickies" />
       
        <xen:hook name="thread_list_threads">
        <xen:foreach loop="$threads" value="$thread">
            <xen:include template="thread_list_item">
                <xen:set var="$showForumLink">1</xen:set>
             </xen:include>

        </xen:foreach>
        </xen:hook>
       
        <xen:edithint template="thread_list_item_edit" />
    <xen:else />
        <li class="primaryContent">{xen:phrase there_no_threads_to_display}</li>
    </xen:if>
    </ol>
 

1BJK903

Active member
#6
Find the code that includes thread_list_item and modify it to set that flag appropriately. It's not necessarily copy/paste. And I am assuming that your "master" forum is an addon that uses the thread_list_item template.
Hi there, can someone help me out with this?

If I use your snippet with forumlink, it shows me the most recent posted forumlink, instead of the unique forums for each post. So for example, if I have showing 15 recent posts, they all get the forumlink of the LAST POSTED forum instead of their own. How can I solve that?
 

Jake Bunce

XenForo moderator
Staff member
#7
Hi there, can someone help me out with this?

If I use your snippet with forumlink, it shows me the most recent posted forumlink, instead of the unique forums for each post. So for example, if I have showing 15 recent posts, they all get the forumlink of the LAST POSTED forum instead of their own. How can I solve that?
That is just a flag. The thread records must have the forum record in them, as you can see in the code from thread_list_item:

Code:
<xen:if is="{$showForumLink}"><span class="containerName">,
					<a href="{xen:link forums, $thread.forum}" class="forumLink">{$thread.forum.title}</a></span></xen:if>
This means checking your thread records to ensure the forum data is there, and possibly modifying the PHP code which fetches those thread records. This is a programming problem and I suggest posting in this forum:

http://xenforo.com/community/forums/xenforo-development-discussions.34/