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

XF 1.2 Ad unit below 5th thread in thread list

Discussion in 'Styling and Customization Questions' started by soloarquitectura, Aug 18, 2013.

  1. soloarquitectura

    soloarquitectura Active Member

  2. Brogan

    Brogan XenForo Moderator Staff Member

    <xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 4>
     
  3. soloarquitectura

    soloarquitectura Active Member

    Thanks. This is for messages, but not for threads.

    In thread_list template, I need something like this:

    Code:
    <xen:hook name="thread_list_threads">
    <xen:foreach loop="$threads" value="$thread">
    <xen:include template="thread_list_item" />
    <xen:if is="{$thread.position} % {$xenOptions.discussionsPerPage} == 4">
    ad unit
    </xen:if>
    </xen:foreach>
    
    Is it posible?
     
  4. Brogan

    Brogan XenForo Moderator Staff Member

    Oh, I misread.

    No, there's no way of doing that using a conditional statement as threads aren't numbered as posts are.

    You could try using li:nth-child(5) and doing it that way.
     
  5. soloarquitectura

    soloarquitectura Active Member

    Yes, that would work. Thank you very much (y)
     
  6. SuperJETT

    SuperJETT Member

    Old thread I know...so use CSS style for li:nth-child(5) to take care of this? CSS is not my strong suit obviously, any help to further explain this would be great.
     
  7. jeffwidman

    jeffwidman Active Member

    @Brogan - any chance you could provide example code for this?

    I'd really like to stick in a banner ad every 7th and 14th thread within the thread_list template, and CSS is not my strong suit.

    I checked the conditional statements resource, and didn't find anything on this (makes sense given your statement above that threads are numbered differently than posts.)

    Too bad we can't just use a template conditional like:
    Code:
    <xen:if is="{$thread.position} % {$xenOptions.discussionsPerPage} == 7">
     
  8. SuperJETT

    SuperJETT Member

    This is what I ended up with in thread_list that puts my ad after the 5th post in a thread listing after the stickied threads. There may be a better way but this works.

    Code:
    <xen:foreach loop="$threads" value="$thread" i="$i">
    <xen:include template="thread_list_item" />
    <xen:if is="!{xen:helper ismemberof, $visitor, 26, 4}">
    <xen:if is="{$i} == 5">
    
     
    Last edited: Jan 15, 2015
    Travis-Mc and Sean Kendle like this.
  9. Brogan

    Brogan XenForo Moderator Staff Member

    You could just use two conditional statements and an OR.
     
  10. jeffwidman

    jeffwidman Active Member

    @SuperJETT Thanks. I hadn't thought of manually getting the thread position myself. Unless Brogan knows a cleaner way to get the thread position, I'll use your solution.


    @Brogan--can you elaborate? Were you thinking of how SuperJETT did this or some other way?

    I've looked everywhere and haven't found any examples of conditional statements triggered by thread position in the thread list...
     
  11. Sean Kendle

    Sean Kendle Member

    Dude, you're a genius! Thanks!!!
     

Share This Page