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

Is there a way to load images based on how many messages are in a thread view?

Discussion in 'XenForo Questions and Support' started by RobinHood, Sep 3, 2012.

  1. RobinHood

    RobinHood Well-Known Member

    This is for a sidebar, I only want it to load 1 image by default, but if there's more than x posts loaded onto the page it should load a second image, and if more than y posts on a page it should load a 3rd image.

    Any ideas?

    Edit: Actually, ideally I'd like to check the height of all the messages, but that could perhaps vary if images are being loaded from an external source?
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Admin CP -> Appearance -> Templates -> thread_view

    Add this code:

    <xen:foreach loop="$posts" value="$post" count="$count">
    Now you can reference {$count} anywhere after this code to check the number of posts on the page. Example:

    <xen:if is="{$count} > 15">
    <xen:elseif is="{$count} > 10" />
    <xen:elseif is="{$count} > 5" />
    RobinHood likes this.
  3. RobinHood

    RobinHood Well-Known Member

    Hmmm...I seem to get the following error on the thread after that:

    Fatal error: Cannot use object of type XenForo_BbCode_TextWrapper as array in /home/domain/public_html/library/XenForo/Template/Abstract.php(265) : eval()'d code on line 663
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    No problems here. What is your code?
  5. RobinHood

    RobinHood Well-Known Member

    I apologize - I've got it working perfectly now!

    Thank you Jake, you're a gentleman and a scholar! :D

Share This Page