• This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

How To Add A Sidebar To Any Forum Page

Jake Bunce

Well-known member
This guide is for adding a sidebar to any forum page. It will be like the one that is already on the index page:

Screen shot 2010-11-10 at 10.01.40 AM.webp

The first question is, on what page do you want to display the sidebar? Then you need to find the root template for that page. See this guide for help finding the root template of a page.

For example, thread_view is the root template for all thread pages. If we want to add a sidebar to that page then edit this template:

Admin CP -> Appearance -> Templates -> thread_view

Then add this code to the bottom of the template:

Code:
<xen:sidebar>

</xen:sidebar>

That will create an empty sidebar that contains only the user block (which is part of the default sidebar). Then you can add your own content to the sidebar by inserting your code between those sidebar tags.

To add formatted content blocks to the sidebar like those seen on the index page (see above picture) you can add code like this:

Code:
<xen:sidebar>
	<div class="section">
		<div class="secondaryContent">
			YOUR CONTENT HERE
		</div>
	</div>
</xen:sidebar>

You can add multiple instances of that code if you want to create multiple content blocks:

Code:
<xen:sidebar>
	<div class="section">
		<div class="secondaryContent">
			YOUR CONTENT HERE
		</div>
	</div>

	<div class="section">
		<div class="secondaryContent">
			EVEN MORE CONTENT HERE
		</div>
	</div>
</xen:sidebar>

If you want to add the same sidebar content to multiple pages then you can put that content into a new template:

Admin CP -> Appearance -> Templates -> Create New Template

Give the template a name (e.g. my_sidebar_content). Then to call on that template you would use code like this when editing the root template:

Code:
<xen:sidebar>
	<xen:include template="my_sidebar_content" />
</xen:sidebar>

There are different ways to organize the sidebar code using templates, but this gives you the general idea. The only other thing I would note is that the user block that is contained in the sidebar by default is contained within this template:

Admin CP -> Appearance -> Templates -> sidebar_visitor_panel

So, for example, if you don't want that user block to appear in your custom sidebar, but you still want it to appear on the index page, then you can cut that code from sidebar_visitor_panel and paste it into forum_list between its sidebar tags.
 
This is the relevant code from the forum_list template:

HTML:
<xen:sidebar>

    <xen:edithint template="sidebar.css" />

    <xen:include template="sidebar_online_users" />

    <div class="section">
        <div class="secondaryContent statsList" id="boardStats">
            <h3>{xen:phrase forum_statistics}</h3>
            <div class="pairsJustified">
                <dl class="discussionCount"><dt>{xen:phrase discussions}:</dt>
                    <dd>{xen:number $boardTotals.discussions}</dd></dl>
                <dl class="messageCount"><dt>{xen:phrase messages}:</dt>
                    <dd>{xen:number $boardTotals.messages}</dd></dl>
                <dl class="memberCount"><dt>{xen:phrase members}:</dt>
                    <dd>{xen:number $boardTotals.users}</dd></dl>
                <dl><dt>{xen:phrase latest_member}:</dt>
                    <dd><a href="{xen:link members, $boardTotals.latestUser}" class="username">{$boardTotals.latestUser.username}</a></dd></dl>
            </div>
        </div>
    </div>

</xen:sidebar>
 
Sorry, one last question. I try the code above and place it in thread_list. The side bar shows all except "Staff Online Now". How do I bring that module over too?

Thanks
 
The Staff Online is in the sidebar_online_users template and is this code:

HTML:
<xen:if hascontent="true">
    <div class="section staffOnline avatarList">
        <div class="secondaryContent">
            <h3>{xen:phrase staff_online_now}</h3>
            <ul>
                <xen:contentcheck>
                    <xen:foreach loop="$onlineUsers.records" value="$user">
                        <xen:if is="{$user.is_moderator} OR {$user.is_admin}">
                            <li>
                                <xen:avatar user="$user" size="s" img="true" />
                                <a href="{xen:link members, $user}" class="username">{xen:helper richUserName, $user}</a>
                                <div class="userTitle">{xen:helper userTitle, $user}</div>
                            </li>
                        </xen:if>
                    </xen:foreach>
                </xen:contentcheck>
            </ul>
        </div>
    </div>
</xen:if>

However, there's an IF statement related to "hascontent=true" so that is probably why it isn't showing up on your template.
I haven't tried it myself, I'm just guessing based on the code.
 
quick question. If I add this, do i have to keep doing it everytime i upgrade?

Not usually.

Template modifications like this are preserved during the upgrade. Sometimes custom templates are incompatible with new versions, but that generally only happens with major upgrades, not with regular point releases.
 
If I want to add a sidebar with the newest members and the highest-posting members on the main page what would that code look like?
 
You would need an add-on for that as that data is not available on the main forum page.

Look in the add-on releases forum, there are a few add-ons which do that.
 
Brogan I'm confused let me ask my question a different way. If I go to my "Members Page" that list all of the members for my site, I see a side bar on the right hand side of the page showing the "Newest Members" and the "Highest Posing Members" being displayed. How can I get these two sidebars displayed on the Forums Main Page (index.php) ?
 
You can't, as I explained above.

That data is not exposed for the forum home, it requires an add-on.
 
Yes.

Or you can check the add-on releases forum to see if someone has already created an add-on which does what you want.
 
Top Bottom