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

XF 1.3 How to put ad only on homepage

Discussion in 'Styling and Customization Questions' started by Robby, May 2, 2014.

  1. Robby

    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?
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

  3. Robby

    Robby Well-Known Member

    I don't see any conditional statements for just displaying on the home page.
    Just with forum id but the homepage doesn't have that.
     
  4. Valhalla

    Valhalla Well-Known Member

    You could modify the forum_list template and add what you want to show accordingly.

    If you want to show something below the navigation, then you should modify above:

    Code:
    <xen:hook name="forum_list_nodes">
        <xen:if is="{$renderedNodes}"><xen:include template="node_list" /></xen:if>
    </xen:hook>
     
  5. Robby

    Robby Well-Known Member

    Do i just have to put a template where it says include template in the code?
     
  6. Brogan

    Brogan XenForo Moderator Staff Member

    If by "home" page you mean the forum list, then:

    How can I show content on a specific page?
    <xen:if is="{$contentTemplate} == 'forum_list'">
    This content will show on the forum list
    </xen:if>
     
  7. Robby

    Robby Well-Known Member

    Yes that's it, thanks man!
    (y)(y)(y)(y)
     
  8. daviden

    daviden Active Member

    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>

    Skärmavbild 2017-04-07 kl. 22.09.17.png



    Is there another way to solve this? Putting my randomize ads on the first/main page - the forum list that is.
     
  9. xenfans

    xenfans Well-Known Member

  10. daviden

    daviden Active Member

  11. xenfans

    xenfans Well-Known Member

    compared viewName against XenForo_ViewPublic_Forum_List, it's what i use to limit showing something on just forum's index.
     
  12. daviden

    daviden Active Member

    How do I use that to define it in my code snippet for randomizing banners then? :/
     
  13. xenfans

    xenfans Well-Known Member

    if we're on the homepage {
    .... your loop here
    }
     
  14. daviden

    daviden Active Member

    So, <xen:if is="{$contentTemplate} == ’XenForo_ViewPublic_Forum_List’”> ?
     
  15. xenfans

    xenfans Well-Known Member

    viewName. Like i said.
     
  16. daviden

    daviden Active Member

    So, where do I write viewName then? I don't know too much about how to define this, or the scripting in the templates.
     
  17. xenfans

    xenfans Well-Known Member

    Let's start at the beginning for you.

    What template are you trying to add your conditionals to, to try and show your random banners? What's the name of that template?
     
  18. daviden

    daviden Active Member

    Same as the one I mentioned above: ad_above_top_breadcrumb
     
  19. xenfans

    xenfans Well-Known Member

    Doesn't show here, because the viewName isn't the XenForo_ViewPublic_Forum_List
    Screen Shot 2017-04-09 at 00.16.07.png


    Does show here, because it matches.
    Screen Shot 2017-04-09 at 00.15.51.png



    Here's how I edited the template.
    Screen Shot 2017-04-09 at 00.15.43.png
     
    daviden likes this.
  20. daviden

    daviden Active Member

Share This Page