Template Conditionals - Front Page Banner Ads

akia

Well-known member
I'm trying to set up some banner ads for my site but the problem I'm having is a leader board dosn't fit on the front page under the top bread crumbs, and a normal size banner looks odd when just viewing a thread etc.

Is there a Template Conditional that I can wrap my ad code up in so that if someone is on the home page it displays one ad code and if elsewhere it displays another.
 

Jake Bunce

XenForo moderator
Staff member
Code:
<xen:if is="{$contentTemplate} == 'forum_list'">
	HOMEPAGE
<xen:else />
	ALL OTHER PAGES
</xen:if>
 

akia

Well-known member
Can you Nest If tags within each other?

Currently I've got:

Code:
<xen:if is="{$contentTemplate} == 'forum_list'">
<xen:if is="{$visitor.user_id}">
<div style="text-align: center; margin-top:8px;">
<script type='text/javascript'><!--// <![CDATA[
    OA_show(1);
// ]]> --></script>
</div>
<xen:else />
<div style="text-align: center; margin-top:8px;">
<script type='text/javascript'><!--// <![CDATA[
    OA_show(2);
// ]]> --></script>
</div>
</xen:if>
<xen:else />
<xen:if is="{$visitor.user_id}">
<div style="text-align: center; margin-top:8px;">
<script type='text/javascript'><!--// <![CDATA[
    OA_show(1);
// ]]> --></script>
</div>
<xen:else />
<div style="text-align: center; margin-top:8px;">
<script type='text/javascript'><!--// <![CDATA[
    OA_show(2);
// ]]> --></script>
</div>
</xen:if>
</xen:if>
Will this work
 

akia

Well-known member
If I wanted to change to instead of showing ads to all members to just members of certain user groups what would I use?
 

Andy.N

Well-known member
Let me piggy back on this thread as well.
I load javascript for a media player in page_container_js_head.
Code:
<script type="text/javascript" src="/jwplayer/jwplayer.js"></script>
However, this player is mostly used for a private node which majority of our members will not see and need to load.

Which condition I should use to load this JS only under node id = x or category id = y?

Thanks Jake ;)
 

Jake Bunce

XenForo moderator
Staff member
Let me piggy back on this thread as well.
I load javascript for a media player in page_container_js_head.
Code:
<script type="text/javascript" src="/jwplayer/jwplayer.js"></script>
However, this player is mostly used for a private node which majority of our members will not see and need to load.

Which condition I should use to load this JS only under node id = x or category id = y?

Thanks Jake ;)
You need to pass the node_id using xen:container. Edit these two templates:

Admin CP -> Appearance -> Templates
> forum_view
> thread_view


Add this line to the top of each template:

Code:
<xen:container var="$forumId">{$forum.node_id}</xen:container>
Now you can use this condition for your javascript:

Rich (BB code):
<xen:if is="{$forumId} == 2">

</xen:if>
 

Andy.N

Well-known member
Now you can use this condition for your javascript:

Rich (BB code):
<xen:if is="{$forumId} == 2">

</xen:if>
Awesome. Would this cover all childs of a node/forum? Or I have I explicitly use them like <xen:if is="{$forumId} == 2, 4,60, 45">
 

Euroman

Active member
Can you guys tell me why my adsense ads don't show on the front page of my forum?

The same code works on other sites but just not here. I'm going crazy over this..

Help :eek:
 

Brogan

XenForo moderator
Staff member
As we discussed in the conversation, the content received from Google is blank.

You will need to speak to Google AdSense about this.
 

Euroman

Active member
I have a green light from Google and my adsense account is all good.

That's why I don't get it... :confused:
 

Euroman

Active member
Code:
<script type="text/javascript"><!--
google_ad_client = "ca-pub-2340283517533441";
/* mlm-forums */
google_ad_slot = "8848259061";
google_ad_width = 250;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
This is the code I use and why note add it to any xenforo forum and see if it works. If it does then we know we have a problem on my forum...
 

RobParker

Well-known member
I have a green light from Google and my adsense account is all good.

That's why I don't get it... :confused:
In case you're not aware, Adsense ads usually take a couple of hours to show up. They'll be blank until then.

If you've waited more than a few hours ignore me.
 

Euroman

Active member
Hi Rob

It's been on for 24 hours :eek:

You are welcome to add my code to your forum just to see if it works
 
Top