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

XF 1.1 How do I add a single Ad within the 1st post only, in a thread?

Discussion in 'XenForo Questions and Support' started by Marco Famà, Feb 20, 2012.

  1. Marco Famà

    Marco Famà Active Member

    Dear all,
    what I would like to achieve is something like what you can see here
    http://forum.telefonino.net/showthread.php?t=858407
    That is, I need to publish my Ad code within the first message of a thread, and nothing more.

    Can this be done with ease? I've seen several post regarding AdSense under the breadcrumb or after the first post. I need it to appear aside.

    thanks guys
    Marco
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    Marco Famà likes this.
  3. Marco Famà

    Marco Famà Active Member

    Great!
    For future reference (maybe it can help someone with the very same question of mine?), this is how I solved it:

    Code:
    <xen:hook name="ad_message_body" />
    <xen:if is="{$post.position} == 0 AND !{$message.conversation_id}">
    <div style="display: block; float: right; vertical-align: middle">
     
    // here it goes my code
     
    </div>
    </xen:if>
    Thanks Brogan, really appreciate your help
    Marco
     
    Roberto Bilić likes this.
  4. samresp

    samresp New Member

    Thanks for the code, really useful!
     
    Marco Famà likes this.
  5. Marco Famà

    Marco Famà Active Member

    If you remove

    {$post.position} == 0 AND

    you'll get the ad within all the pages :)
     
  6. surfsup

    surfsup Well-Known Member

    Digitalpoint has an awesome resource for advertising inside the 1st post itself, bumped me up pretty high..
     
  7. Marco Famà

    Marco Famà Active Member

    ciao Brogan,
    is there another way to edit the following code

    Code:
    <xen:if is="!{$message.conversation_id} AND !{$ajaxInsert} AND {$post.position} == 0">
    to make something appear only in the first post of each page?
    If I remove the AND {$post.position} == 0 the banner gets replicated into ALL posts, and I'm not sure I understood why

    Can you please help Brogan/all?

    Thanks!
    Marco
     
  8. Brogan

    Brogan XenForo Moderator Staff Member

    Marco Famà likes this.
  9. Marco Famà

    Marco Famà Active Member

    Thanks again Brogan! have a nice day
     
  10. Marco Famà

    Marco Famà Active Member

    hey Brogan
    do you know if a conditional statement to check which browser the user is navigating forum froms, is available? Tried searching your link with no result... can you please help?

    Thanks
    Marco
     
  11. Brogan

    Brogan XenForo Moderator Staff Member

  12. Marco Famà

    Marco Famà Active Member

    I see.. but I believe that I should be editing xenforo's template using xenForo syntax, am I wrong? or can I include JS also with no problems at all? :-O
    Sorry for the dumb question...
     
  13. Brogan

    Brogan XenForo Moderator Staff Member

    The templates support HTML, CSS, JS and XenForo syntax.
     
    Marco Famà likes this.

Share This Page