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

How use several times <xen:sidebar> ... </xen:sidebar> in same template ?

Discussion in 'XenForo Development Discussions' started by Allan, Feb 23, 2016.

  1. Allan

    Allan Well-Known Member


    I would like use <xen:sidebar> ... </xen:sidebar> in the same template.

    <xen:sidebar> Content 1 </xen:sidebar>
    <xen:sidebar> Content 2 </xen:sidebar>
    <xen:sidebar> Content 3 </xen:sidebar>

    One variable is displayed instead of 3

    I have not found a solution to run all variables together :(

    An idea ?
  2. Jake B.

    Jake B. Well-Known Member

    I don't think this is possible. Why would you want to use it more than once? o_O
  3. Allan

    Allan Well-Known Member

    For a new add-on :p
  4. Jake B.

    Jake B. Well-Known Member

    Any particular reason you can't have them in one instance of xen:sidebar? I don't think it's built to support appending using multiple tags
  5. Allan

    Allan Well-Known Member

    I have visual constraints forcing me to use several times xen:sidebar.
  6. Allan

    Allan Well-Known Member

    No one would have any idea?
  7. Daniel Hood

    Daniel Hood Well-Known Member

    No, it doesn't really make any sense. If it's in the same template why not just do:

    <xen:if is="{$conditionforsidebarone}">
    <xen:if is="{$conditionforsidebartwo}">
      more content?
    Bob, Jake B. and Mike Creuzer like this.
  8. Allan

    Allan Well-Known Member

    Yes but if you disable both, it will remain just <xen:sidebar> </xen:sidebar>, and my problem is if there are only <xen:sidebar> </xen:sidebar>, and this creates a blank space.


  9. James

    James Well-Known Member

    Can you not utilise <xen:if hascontent="true"> to only display the sidebar if content exists to go in it? Similar to how sidebar_online_users operates.

    Jake B. and Daniel Hood like this.
  10. Allan

    Allan Well-Known Member

    Good idea :)

    As ?

    <xen:if hascontent="true">
                <div class="section">
                Text here ....
  11. Jake B.

    Jake B. Well-Known Member

    contentcheck should probably be inside xen:sidebar, and if you hardcode a div in without it being wrapped in an if it'll always display
  12. Allan

    Allan Well-Known Member

    If be inside xen:sidebar:
  13. James

    James Well-Known Member

    You can have HTML between the if and the content check but I don't believe you can next the content check inside another xenforo template tag (like your sidebar). You may need to readdress your template structure or find another way of hiding it. Nothing springs to mind at present!
  14. Lawrence

    Lawrence Well-Known Member

    If I understand what you are trying to do, I don't think you can. You may have to skip the sidebar tag completely and add in the actual HTML:
    <div class="sidebar" id ="sidebar_1">
    <---- blocks here------>

    I'd give them each their own unique id so you can target each separately for styling or displaying, if needed. You would also be able to use a separate content check for each one this way.
  15. Jake B.

    Jake B. Well-Known Member

    Wrap the xen:sidebar with an if with multiple condition statements

Share This Page