Announcement

Collapse
No announcement yet.

How to Conditionally Show Ad Based on Number of Posts in a Thread and how to Format It

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to Conditionally Show Ad Based on Number of Posts in a Thread and how to Format It

    Hello,

    I have AdSense code I'd like to display on ShowThread but only if the number of posts in the thread being viewed is greater than one. Can that be done without requiring custom code?

    Additionally, for the ad that's being displayed when the number of posts > 1, am I able to use a built-in div class to make the ad, which appears between the first and second posts, look more naturally like the posts above and below it? I'm not talking about displaying it in a deceptive manner; I'm asking if you can display the ad in a format that matches the style (background color, border, etc) that each post appears in? Thanks in advance for the help.

  • #2
    Have you tried:

    <vb:if condition="$post[postcount] === 2">ad code</vb:if>

    That should display an ad between the first and second post if placed at the top of the postbit template.

    For customizing the look, you would have to apply CSS to the DIV or other ad components. You can place these in the additional.css template in your style and they will be included on every page.
    Translations provided by Google.

    Wayne Luke
    The Rabid Badger - a vBulletin Cloud demonstration site.
    vBulletin 5 API - Full / Mobile
    Vote for your favorite feature requests and the bugs you want to see fixed.

    Comment


    • #3
      Originally posted by Wayne Luke View Post
      Have you tried:

      <vb:if condition="$post[postcount] === 2">ad code</vb:if>

      That should display an ad between the first and second post if placed at the top of the postbit template.

      For customizing the look, you would have to apply CSS to the DIV or other ad components. You can place these in the additional.css template in your style and they will be included on every page.
      No, currently, I have the code at the very bottom of postbit_legacy. It's displaying exactly where I want it to between the first and second posts of each page (not just the first and second posts if there are multiple pages); I just don't want it to appear if there's only a single post:

      Code:
      <vb:if condition="($post['isfirstshown']) AND (!is_member_of($bbuserinfo, 5,6,23))">
      Ad code...
      </vb:if>
      How would I do that?

      As far as the look, I have additional.css customized to get the ad code to display in the space between the first and second post. I was just wondering it you could have that "container" that holds the ad inherit the colors, borders, etc. of the container that holds each post so that the ad container looks the same as the post container. It doesn't sound like there's an easy way to do that unless the style settings for the post container are specified in a template and could be copied into the additional.css template.

      Comment

      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
      Working...
      X