Cant show stats on sidebar of all pages - so can we use an IF to set which pages its on?

RickM

Well-known member
Hi all,

I'm adding the sidebar to all pages of our theme.

I ended up moving the sidebar stuff into its own template called 'sidebar' as it would get messy having it at the bottom of the forumlist, threadlist and threadview templates.

I'm getting a PHP error at the top of my page, basically because you apparently cant show stats on anything other than forum home.

So my question is:

1) Is it possible to allow those stats to work on the thre templates mentioned above.

if NOT, what is the <xen:if> condition for making it so I can include the stats bits only on the homepage?

Here's a copy of my sidebar template if it helps:

Code:
<xen:sidebar>

	<xen:edithint template="sidebar.css" />
	<xen:include template="sidebar_online_users" />
	<div class="section">
		<div class="statsList" id="boardStats">
			<h3>{xen:phrase forum_statistics}</h3>
			<div class="pairsJustified sideContent">
				<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>
 
The stats are not available because the variables are only available on forum home. You can create a listener to make the variables available to other templates.

If you do not want to do that then add <xen:sidebar> </xen:sidebar>to each template you want it in, and place data that is available between the two tags.
 
That would make it worse :/

One sec - I'll explain better.

I want a sidebar the same on all pages. The only difference is, on the homepage I want it to still display the stats and such that it currently does. So I need some form of if statment in there saying 'if we're on the home page - load the sidebar stats template - otherwise carry on'.

I've moved ALL sidebar stuff to another template (again, having it in the foot of each-page will be a massive headache to update, so I've put it all in one template which is then included where the <xen:sidebar> stuff would usually go.

It works fine - its just this if statement to get the stats template to only be included on the home page.

I would guess its something along the lines of <xen:if condition="THIS_PAGE == home">-- INCLUDE HERE --</xen:if> but I cant seem to find out what it is.
 
XenForo does not use anything like THIS_SCRIPT. I been looking at how to accomplish what you would like done with a listener to listen for a template name.
 
Hi Lawrence - thanks for taking the time to look into this :)

I'm a little worried about the templating system. It does seem fairly limiting in comparison to the years old vB3 one (I know I shouldn't really be comparing but its inevitable).

I love how the new tabbed layout works and everything, but not being able to do conditional if statements for something as simple as checking the page you're on seems silly (unless I'm missing something of course?).

Really hope this gets sorted out before it goes Gold. A global sidebar is a huge priority and I'm sure there are a large number of other situations where conditionals would need to be used.
 
Top Bottom