Announcement

Collapse
No announcement yet.

How do I add PHP includes?

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

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

    Comment


    • #17
      How do I include it in the actual template?

      <?php echo $var ?>

      Is there a special code to do this?

      Comment


      • #18
        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 ?>

        Comment


        • #19
          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.

          Comment


          • #20
            $navbar or $footer are already being used.

            What about $navbar_addon and $footer_addon?

            Comment


            • #21
              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.

              Comment

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