Announcement

Collapse
No announcement yet.

How do I add PHP includes?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • cybermomcafe
    replied
    Here is what I had to use to get it working on my site (I'm using it for links from ZTMC).

    Code:
    ob_start();
    include('ad_network_405.php');
    echo $ad_network;
    ob_end_clean();
    And to call it from within a template all you have to do is simply put the variable that you defined in the include ($ad_network) in my example.

    You would change 'ad_network_405.php' to reflect the file you are including, and $ad_network to reflect the variable that you want to use to call the contents of the file. For my site, I simply put the $ad_network at the bottom of the footer template and it worked fine.

    It wouldn't work without the echo before the variable and I had to take off the stuff after the variable...it wouldn't display the links with that there either.

    Leave a comment:


  • feldon23
    replied
    $navbar or $footer are already being used.

    What about $navbar_addon and $footer_addon?

    Leave a comment:


  • techxpert
    replied
    Originally posted by Chroder
    You will still have to create a new plugin To get the output of your included content to appear where you want them to in the templates, then you'll have to use some output buffering and capture them in a template.

    PHP Code:
    ob_start();
     
    include(
    'navbar.php');
    $navbar ob_get_contents();
     
    ob_clean();
     
    include(
    'footer.php');
    $footer ob_get_contents();
     
    ob_end_clean(); 
    Then you can use $navbar and $footer in your templates.

    Ah Colin beat me

    This does not work and this was admitted in other thread.

    Leave a comment:


  • feldon23
    replied
    You cannot put PHP in a template.

    If a variable has been defined and is available to the template, just put the variable name. $var instead of <?php echo $var ?>

    Leave a comment:


  • 2ksports
    replied
    How do I include it in the actual template?

    <?php echo $var ?>

    Is there a special code to do this?

    Leave a comment:


  • I, Brian
    replied
    A picture is worth a thousand words - many thanks for that, both of you - finally got the issue resolved.

    Leave a comment:


  • vbStartup
    replied
    Look at the below screenshot

    http://img14.imageshack.us/img14/3070/plugin1ta.png

    Ah... Colin explained it before I finished the screenshot.

    Leave a comment:


  • Colin F
    replied
    No problem Goto your

    AdminCP > Plugin System > Add New Plugin

    Give it a name and select 'global start' as the hook location, and input the code above, adjusted to your needs. Mark the plugin as active and Save it.

    Also, make sure that you have plugins turned on globally in your vBulletin Options.

    Leave a comment:


  • I, Brian
    replied
    Add a new global_start plugin
    I'm afraid I have no idea what you're talking about.

    Normally I'd include that code in the "phpinclude_start" in 3.0, but since upgrading to 3.5, I have no idea what the procedure is - I know there's a "plugin system" but have no idea how it's supposed to be used.

    Leave a comment:


  • Chroder
    replied
    You will still have to create a new plugin To get the output of your included content to appear where you want them to in the templates, then you'll have to use some output buffering and capture them in a template.

    PHP Code:
    ob_start();

    include(
    'navbar.php');
    $navbar ob_get_contents();

    ob_clean();

    include(
    'footer.php');
    $footer ob_get_contents();

    ob_end_clean(); 
    Then you can use $navbar and $footer in your templates.

    Ah Colin beat me

    Leave a comment:


  • Colin F
    replied
    You can't include directly in the templates.

    Add a new global_start plugin and use the following code:
    PHP Code:
    ob_start();
    include_once(&
    #8216;/path/to/file.html’);
    $included_file ob_get_contents();
    ob_end_clean(); 
    Then, use the $included_file variable in the templates.

    Leave a comment:


  • I, Brian
    replied
    Ah - I'm confused now. What is the procedure for including include statements - nothing more than adding an include statement in the header/footer??

    Leave a comment:


  • Colin F
    replied
    That won't work, as the fetch_template function only fetches/parses templates and not files.
    To include a file, use
    Code:
    include('./navbar.php');

    Leave a comment:


  • I, Brian
    replied
    Many thanks for the help - much appreciated.

    Leave a comment:


  • vbStartup
    replied
    Close But it should be:

    PHP Code:
    eval('$navbar = "' fetch_template('navbar') . '";'); 
    Then call it by $navbar
    Last edited by vbStartup; Sun 9 Oct '05, 9:01am.

    Leave a comment:

widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...
X