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

Template Conditionals - Front Page Banner Ads

akia

Well-known member
#1
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.
 

akia

Well-known member
#4
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
#6
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
#8
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
#10
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:

Code:
<xen:if is="{$forumId} == 2">

</xen:if>
 

Euroman

Active member
#13
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
#14
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
#16
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...