Announcement

Collapse
No announcement yet.

Optimize this postbit code

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

  • Optimize this postbit code

    Hello,
    I need to modify the postbit template to display something after the 1st post and the 10th post of every page.

    I have added this at the end of the postbit template

    Code:
    <if condition="$post[postcount] == 1 OR $post[postcount] % 26 == 0">
    <!-- Content to show after 1st post of every page  -->
    </if>
    
    <if condition="$post[postcount] == 10 OR $post[postcount] % 36 == 0">
    <!-- Content to show after 10th post of every page  -->
    </if>
    It works fine on the fist page, and on the second. But after the second page, the code appears later that when is supposed. I have the “Maximum Displayed Posts Before Page Split” set to 25. (do I need to modify that to another value in order to work?)

    What can I do to show what I need after the 1st and 10th post of every page?

    Thanks…

  • #2
    Let's take a look at the first part of your code:
    Code:
    <if condition="$post[postcount] == 1 OR $post[postcount] % 26 == 0">
    <!-- Content to show after 1st post of every page  -->
    </if>
    The first post affected by this code is your first post, then your 26th post - which is the first post on your second page.
    Then.. it's the 52nd post.. that is the second post of your third page.

    Same thing with the second part. First the 36th post and then the 72nd post.

    Replace your code with this:
    Code:
    <if condition="$post[postcount] - 1 % 25 == 0">
    <!-- Content to show after 1st post of every page  -->
    </if>
    
    <if condition="$post[postcount] - 10 % 25 == 0">
     <!-- Content to show after 10th post of every page  -->
     </if>
    I am not completely sure if this will work, maybe you have to do something like this:
    '(postcount - 1) % 25'
    Instead of this:
    'postcount - 1 % 25'
    But I am not sure. Give it a try.
    vBulletin 4 Skins

    Comment


    • #3
      Hi!

      The code:
      Code:
      <if condition="($post[postcount] - 1) % 25 == 0">
      <!-- Content to show after 1st post of every page  -->
      </if>
      
      <if condition="($post[postcount] - 10) % 25 == 0">
      <!-- Content to show after 10th post of every page  -->
      </if>
      Did the work I needed.... thanks!

      Comment


      • #4
        Thought it'd work
        I wasn't sure if the '()' characters were allowed in vB conditionals but I'm glad it works.
        vBulletin 4 Skins

        Comment

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