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

how to change / remove the container from page nodes

Discussion in 'XenForo Development Discussions' started by Jake Bunce, Jul 23, 2012.

  1. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I got this question via PM, but I am posting the answer here.

    This requires a little bit of code. Create this file:

    library/Callback/PageNode.php

    Code:
    <?php
    
    class Callback_PageNode
    {
    	public static function noContainer(XenForo_ControllerPublic_Abstract $controller, XenForo_ControllerResponse_Abstract &$response)
    	{
    		$response->containerParams['containerTemplate'] = 'mycontainer';
    	}
    }
    
    It names a new container template (to replace PAGE_CONTAINER). Then you need to create that template:

    Admin CP -> Appearance -> Templates -> Create New Template

    The template needs to contain this at a minimum:

    Code:
    {xen:raw $contents}
    
    That will output just the content of the page without any "html wrapper" which would normally be part of the container. You can surround that code with html if you wish, such as a standard <html><head><body> skeleton.

    Note that there is also a lesser container of sorts for page nodes which is usually called the content template:

    Admin CP -> Appearance -> Templates -> pagenode_container

    The rendered output of this template is what is normally inserted into the container. You can override that template name like this:

    Code:
    <?php
    
    class Callback_PageNode
    {
    	public static function noContainer(XenForo_ControllerPublic_Abstract $controller, XenForo_ControllerResponse_Abstract &$response)
    	{
    		$response->containerParams['containerTemplate'] = 'mycontainer';
    
    		$response->templateName = 'mycontent';
    	}
    }
    
    Then you need to create that template:

    Admin CP -> Appearance -> Templates -> Create New Template

    At a minimum it should contain this code to output the template html for your page node:

    Code:
    {xen:raw $templateHtml}
    
    And after all of this... you need to specify the callback when adding/editing your page node. The callback is:

    Callback_PageNode::noContainer
     
    EQnoble, Brogan, novice and 2 others like this.
  2. Diana

    Diana Active Member

    Thank you Jake. I'm going to try to wrap my brain around this and hopefully be able to follow your directions.
     
  3. Osman

    Osman Member

    Is it possible to explain this subject in detail, step by step?
     

Share This Page