XF 1.3 How to put ad only on homepage

Robby

Well-known member
Hello,

I would like to put an ad on the first page below the top breadcrumb. How can i prevent it to be shown on other pages?
 
Hi, sorry for bringing up a super old thread.
I'm using this for showing ads in my ad_above_top_breadcrumb, works fine. Then I wanted to randomize some ads, and it works fine for this rule: <xen:if is="{$forum.node_id} == 'number of forum'">

But I get a syntax error when I try to put my randomize code in <xen:if is="{$contentTemplate} == 'forum_list'">

The randomize code is like this:

<xen:if is="{$contentTemplate} == ’forum_list’”>
<xen:set var="$banners.1"><a href="ad1.php" target="_blank"><img src="ad1.jpg" width="100%" alt="ad 1"></a></xen:set>
<xen:set var="$banners.2"><a href="ad2.php" target="_blank"><img src="ad2.jpg" width="100%" alt="ad 2"></a></xen:set>
{xen:raw '$banners.{xen:calc '({$serverTime} % 2) + 1'}'}
</xen:if>

View attachment 150892



Is there another way to solve this? Putting my randomize ads on the first/main page - the forum list that is.
The reason you get a syntax error is because of the reverse quotes you've used in the first line.

Rich (BB code):
<xen:if is="{$contentTemplate} == forum_list’”>
<xen:set var="$banners.1"><a href="ad1.php" target="_blank"><img src="ad1.jpg" width="100%" alt="ad 1"></a></xen:set>
<xen:set var="$banners.2"><a href="ad2.php" target="_blank"><img src="ad2.jpg" width="100%" alt="ad 2"></a></xen:set>
{xen:raw '$banners.{xen:calc '({$serverTime} % 2) + 1'}'}
</xen:if>
 
Doesn't show here, because the viewName isn't the XenForo_ViewPublic_Forum_List
View attachment 150952


Does show here, because it matches.
View attachment 150953



Here's how I edited the template.
View attachment 150954
Tried this, got the same error. :/

<xen:if is="{$viewName} == ’XenForo_ViewPublic_Forum_List’”>
<xen:set var="$banners.1"><a href="ad1.php" target="_blank"><img src="ad1.jpg" width="100%" alt="ad 1"></a></xen:set>
<xen:set var="$banners.2"><a href="ad2.php" target="_blank"><img src="ad2.jpg" width="100%" alt="ad 2"></a></xen:set>
{xen:raw '$banners.{xen:calc '({$serverTime} % 2) + 1'}'}
</xen:if>

"The following templates contained errors and were not saved: ad_above_top_breadcrumb: Line 117: Template syntax error."
 
Tried this, got the same error. :/

<xen:if is="{$viewName} == ’XenForo_ViewPublic_Forum_List’”>
<xen:set var="$banners.1"><a href="ad1.php" target="_blank"><img src="ad1.jpg" width="100%" alt="ad 1"></a></xen:set>
<xen:set var="$banners.2"><a href="ad2.php" target="_blank"><img src="ad2.jpg" width="100%" alt="ad 2"></a></xen:set>
{xen:raw '$banners.{xen:calc '({$serverTime} % 2) + 1'}'}
</xen:if>

"The following templates contained errors and were not saved: ad_above_top_breadcrumb: Line 117: Template syntax error."
Look at my post just above your last reply.
 
The reason you get a syntax error is because of the reverse quotes you've used in the first line.

Rich (BB code):
<xen:if is="{$contentTemplate} == forum_list’”>
<xen:set var="$banners.1"><a href="ad1.php" target="_blank"><img src="ad1.jpg" width="100%" alt="ad 1"></a></xen:set>
<xen:set var="$banners.2"><a href="ad2.php" target="_blank"><img src="ad2.jpg" width="100%" alt="ad 2"></a></xen:set>
{xen:raw '$banners.{xen:calc '({$serverTime} % 2) + 1'}'}
</xen:if>
Must been a paste thing, I get the same error with '
 
When I edit, I don't paste to iMsg or use some service to get code to a developer or into my system as they rewrite the ' and " sometimes, and it's hard to spot with all the font changes
I use a text editor on my Mac like TextMate from Macromates, or Sublime Text. On Windows systems I use Notepad++ or UltraEdit, they leave even line breaks in tact in most situations.
It's also why I try to put most of my 'use this code' instructions within [code]..[/code] so it's stripped and 'as inserted'.
The web is a crazy place
 
Top Bottom