vB4 - Including external .php file (Help)

Discussion in 'PHP' started by digitalmikey, Nov 26, 2010.

  1. #1
    Hello I am trying to include a header file from my website above my vBulletin 4 forum so I can get it to match my website more. Now I've read and searched so much on this topic and get the same responses or articles on it which unfortunately has not solved my problem.

    Let me list what I have done.

    Created a plugin with a "global_start" hook location:

    ob_start();
    include('../header.php');
    $myheaderphp = ob_get_contents();
    ob_end_clean();
    Code (markup):
    Next I inserted the following code on the first line of my header template:

    {vb:raw $myheaderphp}
    Code (markup):
    Now for some reason it isn't showing at all. I've messed with my path to the file and everything for hours now and I'm starting to bang my head off the wall. Any suggestions or knowledge you may have will be greatly appreciated. Thanks in advance!
     
    digitalmikey, Nov 26, 2010 IP
  2. drctaccess

    drctaccess Peon

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    0
    #2
    ob_start();
    include('../header.php');
    $myheaderphp = ob_get_contents();
    ob_end_clean();
    var_dump($myheaderphp);


    Can you post the output of above script ?
     
    drctaccess, Nov 27, 2010 IP
  3. digitalmikey

    digitalmikey Guest

    Messages:
    52
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Output is:

    string(0) "" 
    Code (markup):
     
    digitalmikey, Nov 27, 2010 IP
  4. drctaccess

    drctaccess Peon

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    0
    #4
    that's the reason you do not get any output... that object is EMPTY .. that's why you do not see anything

    you should check header.php and see if it outputs something... if not.. your object will always be empty.

    I hope this helps
     
    drctaccess, Nov 27, 2010 IP
  5. digitalmikey

    digitalmikey Guest

    Messages:
    52
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks but I had something in it before but decided to remove it to start fresh.

    It works but as soon as I remove "var_dump($myheaderphp);" the header goes away. Any ideas?
     
    digitalmikey, Nov 27, 2010 IP
  6. digitalmikey

    digitalmikey Guest

    Messages:
    52
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Since I am using VB4 wouldn't I have to preRegister the variables? If so where would I place this line of code?

    vB_Template::preRegister('header',array('includedphp ' => $myheaderphp));  
    Code (markup):
     
    digitalmikey, Nov 27, 2010 IP