Announcement

Collapse
No announcement yet.

Please explain phpinclude template.

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

  • Please explain phpinclude template.

    will someone please explain in details how to use phpinclude template.

    I figured out alot of features on my own without any documentation, but this one I just can't get to work.

    1) How do I set the variable in phpinclude template?

    2) How do I use this new variable in other templates?

    Please be as detailed as possible. I mean step-by-step instructions.

    I'm sure I'm not the only one struggling with this one.
    'beta tester'

  • #2
    Unless you specify variables yourself in the phpinclude template, it won't create any. It's just a template that is parsed as regular PHP code. Nothing more, nothing less.

    Comment


    • #3
      Not exactly the step-be-step answer I was looking for.

      This is what I did:
      In phpinclude I put this:
      $myfooter = include("/path/to/mysite/htdocs/footer.htm");

      I was hoping to just call $myfooter in the forum footer template and include my site's footer this way

      However, my site's footer now appears on top of forum pages.

      I remember seeing someone else having similar problem.

      Is this a bug or am I doing something wrong?
      'beta tester'

      Comment


      • #4
        I am looking for an answer to this also.

        Comment


        • #5
          You can't print things out directed in the phpinclude template -- you have to assign them to $header and $footer respectively.

          Comment


          • #6
            I've now read every post that had the word phpinclude in it and I'm still not sure of exactly how to use it.
            I believe that if you set a variable in the phpinclude template you will be able to use that variable in a template. However, I have run into issues depending on what you set that variable to. I would like to be able to call a php function with a variable, from one of my templates. I can put the require into the phpinclude template with no problem, however, setting the variable which will call the function has given me nothing but problems: Either the function just gets called and included at the top of the page (before any html output) or I get a 'headers already sent' error and the function never gets called.
            Can anyone shed a little light on this template? It seems like there is tons of power here, but it doesn't simply act like a php script...nor as a template.
            Thanks!

            Comment


            • #7
              I asked about how to use phpinclude several times and now has given up on it.

              I got nothing but some very technical answers. I am not a programmer, so I still have no clue.

              All I want to do is to include a common element of my site inside the forum footer file and a banner inside a header file.

              I am hiring a programmer to rewrite my site in php soon, hopefully he will be able to figure out the phpinclude mistery.
              'beta tester'

              Comment


              • #8
                An excerpt from my notes....

                PHPInclude:

                The PHPInclude template is a general purpose template that unlike the others is parsed as PHP code. This PHP Code can be used to enhance your vBulletin installation.

                When using the PHPInclude template you do not want to output anything with eval() or print(), instead you want to assign it to variables.

                If you were going to include a site header you would want to place everything in the $header variable.

                i.e.: $header="This is my site header";

                You can also specifiy variables here for use in other templates.

                Once defined you will be able to use them everywhere. However actually programming in PHP is required and that is beyond the scope of this document. You can find out more about PHP by going to http://php.net and reviewing the manual which is available in HTML and PDF formats.

                Since anything PHPINCLUDE is processed first and on every page, this template makes a great place to add in new functionality. This is almost like a modular system for hacks and will allow you to update your BBS simply and easily.
                Translations provided by Google.

                Wayne Luke
                The Rabid Badger - a vBulletin Cloud demonstration site.
                vBulletin 5 API

                Comment


                • #9
                  For ex..

                  You could place

                  $time = time();

                  In your phpinclude template and then access $time from and of your other templates.

                  In my phpinclude template I only have:

                  include('header.php');
                  include('footer.php');


                  And in those files is the html code to my footer and header in the form of

                  $header = "<table width(...)";

                  You could place that directly into the phpinclude template but I like to keep it clean while having the same header/footer files also available to other scripts.

                  You could also do:

                  $header = implode('', file("http://www.domain.com/include/file.php"));

                  or if you have php4 you could do:

                  // This code is PHP4 ony:
                  ob_start();
                  require("yourheader.html");
                  $header = ob_get_contents();
                  ob_end_clean();

                  Comment


                  • #10
                    Here is my phpinclude template this is currently in development:
                    Code:
                    // Set Needed Variables..
                    $scriptpath=$REQUEST_URI;
                    include ("./admin/nightly.php");
                    // New Functionality
                    include ("./rewards_functions.php");
                    include ("./related.php");
                    // Update User Location on every page.
                    $DB_site->query("UPDATE session set location='".addslashes($scriptpath)."' where sessionhash='$session[sessionhash]'");
                    Translations provided by Google.

                    Wayne Luke
                    The Rabid Badger - a vBulletin Cloud demonstration site.
                    vBulletin 5 API

                    Comment


                    • #11
                      On your way to making your own Who's Online for version 2.0?

                      Comment


                      • #12
                        Thanks freddie it worked!

                        // This code is PHP4 ony:
                        ob_start();
                        require("/usr/local/apache/sites/htdocs/footer.htm");
                        $myfooter= ob_get_contents();
                        ob_end_clean();

                        I just put myfooter in the template and it works.

                        But how do I also include the leftnav.htm in the header?
                        What I need to know is how to set more than one variable to be included in the forum header also?
                        Last edited by Mitrofan; Sun 4 Mar '01, 7:35pm.
                        'beta tester'

                        Comment


                        • #13
                          You guys rock!
                          I finally got everything working the way I wanted. That PHP4 code with the ob_get_contents(); is genius. Allows you to basically run a function and assign the results to a variable.
                          Thank you very much!

                          Comment


                          • #14
                            Originally posted by freddie
                            On your way to making your own Who's Online for version 2.0?
                            Wondered how long it would be before someone caught that.
                            Translations provided by Google.

                            Wayne Luke
                            The Rabid Badger - a vBulletin Cloud demonstration site.
                            vBulletin 5 API

                            Comment


                            • #15
                              urgs, I put this in the template phpinclude :
                              PHP Code:
                              ob_start(); 
                              require(
                              "/url/to/bannerbar.php"); 
                              $bannerbarob_get_contents(); 
                              ob_end_clean(); 
                              the file bannerbar.php has virtual commands in it to include the banners:
                              PHP Code:
                              ..... 
                              <? virtual("/cgi-bin/bannerrotator.cgi?group=forumdisplay"?>
                              .....
                              now this it what happened: without placing $bannerbar in any of my templates, just by putting the above code in the phpinclude-template, the banners appeared !!!

                              But I get the error:
                              Warning: Cannot add header information - headers
                              already sent by (output started at /url/to/bannerbar.php:9) in
                              ./admin/functions.php on line 1088

                              what happened here?

                              Comment

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