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

Banner ad on the home page only

Discussion in 'XenForo Questions and Support' started by LDW, Mar 14, 2013.

  1. LDW

    LDW Member

    Banner ad on the home page only. How can I use the ad_above_content and create a rotating banner for the home page only?
    Then create for onther pages?
     
    RoldanLT likes this.
  2. RoldanLT

    RoldanLT Well-Known Member



    Anyway, this is your friend on skype :)
     
  3. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Code:
    <xen:comment>DEFINE AND RANDOMIZE YOUR BANNERS</xen:comment>
    
    <xen:if is="{$contentTemplate} == 'forum_list'">
    	<xen:set var="$banners.1">banner one for index page</xen:set>
    	<xen:set var="$banners.2">banner two for index page</xen:set>
    	<xen:set var="$banners.3">banner three for index page</xen:set>
    	<xen:set var="$banners.4">banner four for index page</xen:set>
    <xen:elseif is="{$contentTemplate} == 'thread_view'" />
    	<xen:set var="$banners.1">banner one for thread page</xen:set>
    	<xen:set var="$banners.2">banner two for thread page</xen:set>
    	<xen:set var="$banners.3">banner three for thread page</xen:set>
    	<xen:set var="$banners.4">banner four for thread page</xen:set>
    	<xen:set var="$banners.5">banner five for thread page</xen:set>
    <xen:else />
    	<xen:set var="$banners.1">banner one for all other pages</xen:set>
    	<xen:set var="$banners.2">banner two for all other pages</xen:set>
    	<xen:set var="$banners.3">banner three for all other pages</xen:set>
    </xen:if>
    
    <xen:foreach loop="$banners" value="$curBanner" i="$i" count="$count">
    	<xen:if is="!{$rand}">
    		<xen:set var="$rand">{xen:calc '({$serverTime} % {$count}) + 1'}</xen:set>
    	</xen:if>
    	<xen:if is="{$i} == {$rand}">
    		{xen:raw '$banners.{$rand}'}
    	</xen:if>
    </xen:foreach>
    
    Add more elseif's to check more pages.

    For reference:
    http://xenforo.com/community/resources/display-a-random-banner.375/
    http://xenforo.com/community/threads/1-0-0-b1-how-to-identify-the-root-template-of-a-page.5591/
     
    tajhay likes this.
  4. tajhay

    tajhay Well-Known Member

    hi jake, is there code so it checks the url and if the url contains 'sportsbook' for example, then it displays a banner ad just below the top breadcrumbs?
     
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    You can check the URI like this:

    http://xenforo.com/community/threads/template-if-url-is.33789/#post-384503

    But there is no substring function available to the templates, so you can't do a condition exactly like you want.
     
    tajhay likes this.

Share This Page