Positioning a template hook / php include

emma57573

Member
I have created my php include header and footer and popped the add on into the themplate.

On the pages with no side bar like the post views etc everything is looking great. However on the pages that contain the side bar, its trying to pop the template hooks inside the sidebar so I end up with a mashed up page where my includes have been forced into the sidebar css.

Ive checked conflicting CSS names and Ive tried placing my hook in various places in the template.

If I take the sidebar styles out it works again but obviously thats not what I want.

Any light of where I could be going wrong would be great fully received.

EDIT:See last post for latest update on this
 
Im calling the PHP using <xen:hook name="include_php"></xen:hook>
I noticed thats the same way some of the sidebar is called? Could this be the conflict?
 
Still struggling with this. Ive tried taking everything out of my includes and typing just 'hello' with no styles to see if its something within my include conflicting and it made now difference.

The top image is my header include on the pages without the sidebar and the bottom one is on the pages with the side bar. You can see its processing the include from inside the sidebar as its trying the push the include into a 250 width and float:left.

If I have those things out of the sidebar css my include works but I want a side bar also!!

The <xen:hook name="include_php"></xen:hook> is within the page container. But it doesn't matter where I put it in the template files, header, footer etc it make no difference I get the same results.

This is a hair pulling annoyance! Such a silly thing that I thought would be simple!


This is whats in my plugin

PHP:
<?php
class php_include_plugin
{
   
   
    public static function templateHook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
    {
        if($hookName == 'include_php')
        {
            $contents.= include_once("../myheader.php");
 
   
        }
    }
}
 
Right my hair is now getting very thin!! arrrhhh

Thought I was getting somewhere this afternoon...

I decided it would be a better practise to add my header as a new template style instead of trying to include my existing site template. However I have a category menu that runs from the database in a loop so I have to include that (unless I can do this another way? )

So I create a New template called 'site_header_wrapper' to be called from PAGE_CONTAINER

So this is what that templateCreate looks like

PHP:
<?php
class php_include_plugin
{
        public static function templateCreate($templateName, array &$params, XenForo_Template_Abstract $template)
        {
                    if($templateName == 'PAGE_CONTAINER')
                    {
                        $template->preloadTemplate('site_header_wrapper');
                    }
             
        }
 
 
 
    public static function templateHook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
    {
        if($hookName == 'page_container_head')
        {
            $contents.= $template->create('site_header_wrapper');
 
 
        }
    }
}


and this is the site wrapper code:

Code:
<xen:require css="site_header_wrapper.css" />
<div id="nav_bar">MY NAV BAR CODE</div>
<div id="tab">MY TAB BARS</div>
<div id="main_containerforum">
<div id="nav_header">MY LOGO</div>
<form name="form" method="post" action="MY FORM" class="form"> FORM STUFF</form>
<div id="slogan">MY SLOGAN LOGO</div>
<xen:hook name="php_include_catbar" ></xen:hook>
<xen:include template="site_header_wrapper_js" />

So I was pleased that that worked yippee!!! See image



Then I just thought great I can now just add my include to the site wrapper template as you can see I popped in above
The code for that is

Code:
<?php
class php_include_catbar
{
 
 
    public static function templateHook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
    {
        if($hookName == 'php_include_catbar')
        {
            $contents.= include_once("../my_catbar.php");
 
 
        }
    }
}

At the moment all I have in the include is simple text 'Hello world' to rule out conflict with my code and simplify things while I'm working on the issue.

Right so now it falls apart again!!!! and shoved the whole site into the sidebar styles, It also pushes my include to the top of the page instead of neatly inside my navbar as I had hoped, I can't for the life of me work out why this is Image below
 

Attachments

  • Screen Shot 2012-04-18 at 19.33.03.webp
    Screen Shot 2012-04-18 at 19.33.03.webp
    23.5 KB · Views: 16
  • Screen Shot 2012-04-18 at 19.32.24.webp
    Screen Shot 2012-04-18 at 19.32.24.webp
    37.5 KB · Views: 23
Just noticed on the page with the sidebar style issues with the include

There is a rather strange number '1' in the middle of the header, could this be a error code of some kind that would give me a clue?
 
SOLVED!!!!! looks like it was an issue with my formatting of the include that xenforo didn't like.

PHP:
<?php
class php_include_catbar
{
 
 
    public static function templateHook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template)
    {
        if($hookName == 'php_include_catbar')
        {
 
 
 
  ob_start();
        require_once '../my_catbar.php';
        $contents = ob_get_contents();
        ob_end_clean();
     
 
        }
    }
}

That fixed it
 
Top Bottom