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

XF 1.1 Move template ousite of the main container

Discussion in 'XenForo Questions and Support' started by Mathis Neumann, Jan 18, 2013.

  1. Hi there,
    I would like to simply move a template to another position. The best way to explain this is via an example:
    Let's take Xenporta and it's news slider (http://8wayrun.com/). If you take a look at the source code or use firebug to analyze the div on the 8wayrun.com, you can see that the slider is inside of the maincontainer div. What I would like to do now is putting that slider at the position where the advertisement is (or if you use an adblocker, the message to support the site by disabling it).

    How can I do that. (I even use the same design as 8wayrun.

    Thanks and greetings from Germany,
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    You can edit the container template:

    Admin CP -> Appearance -> Templates -> PAGE_CONTAINER
  3. hmm. The problem is that variables are not parsed, even if you are on the site where the addon is shown in this case on the portal page.
    Is there a easy way to change which template hooks an addon/template is using?
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  5. Hmm... does not seem to work. The variable is empty in the page container, could there be a problem with arrays?
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  7. hmm, ok.
    So I have a page (showcase plugin, so showcase index) which contains several boxes in the main content area which are single template files. In the featured items template is {$featuredItems} which I would need in the page container template. How I understood that is that I only can pass variables in the root template of that site, so showcase_index? I tried that and noticed that the index does not have access to {$featuredItems}. Is there a way/should I bypass this from featured_items -> index -> page container?
  8. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    What code are you using? To pass {$featuredItems} you would use this:

    <xen:container var="$featuredItems">{$featuredItems}</xen:container>
    Of course the variable must be available in the content template before you can pass it to the container. xen:container may actually work in other templates as long as those template are evaluated before the container.
  9. did that.
    Not sure about the last part, can I check on that?
  10. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Debug it by adding {$featuredItems} somewhere in the template to see if it outputs anything on the front end.
  11. it's an array and does not seem to have a direct output....
  12. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    You can dump the array with this template code:

    {xen:helper dump, {$featuredItems}}
    Mathis Neumann likes this.
  13. Hmm, so the dumping works in even in the index template of the addon (added dump in first line, outputs array contents correctly)
    {xen:helper dump, {$featuredItems}}
    using the correct template, but adding "<xen:container var="$featuredItems">{$featuredItems}</xen:container>" to the first line of the index template and dumping it again, this time in page_container, does return just "NULL".
    So did I use xen:container correctly or is it just not possible?

    PS: Very helpful dump feature! Thanks :)
  14. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Yep, it looks correct. Give me a URL and admin login and I can take a look.
  15. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Got it working. I had to use this in the container since the var contained HTML output:

    {xen:raw $featuredItems}
    And in the content template I found that the actual output was a template call, so I had to pass the template call as the value:

    	<xen:if is="{$featuredItems}">
    		<xen:container var="$featuredItems"><xen:include template="nflj_showcase_module_featured_items" /></xen:container>
    Then I also edited the nflj_showcase_module_featured_items template and uncommented the section divs so it has a box container in the new location.
  16. I think I love you! Thanks Jake! You're awesome! :)

Share This Page