Announcement

Collapse
No announcement yet.

How do I add PHP includes?

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

  • How do I add PHP includes?

    Not quite sure how to add PHP include statements anymore - comments/recommendations welcome.


  • #2
    to pages or the headerinclude thingy?

    if pages its
    PHP Code:
    include("filename.extension"); 

    Comment


    • #3
      The phpinclude templates are no longer used. You just create a new Plugin at the global_start and/or global_complete hook and put your PHP code in there.
      vBulletin v3.8.0's Implementation of Google Adsense Should Be Avoided At All Costs - Do Your Own Adsense Implementation

      Comment


      • #4
        I'm sorry - I don't understand what you mean about creating a new plugin.

        All I want to do is call up sections of a pre-built template into the header and footer templates, as I call up my site design in php include statements.

        Comment


        • #5
          AdminCP -> Plugin System -> Add New Plugin

          For the hook location select 'parse templates'

          Then enter a title so you can easliy identify it if you ever want to change it

          For the PHP code, enter the following:

          PHP Code:
          eval('$varname = "' fetch_template('templatename') . '";'); 
          Replacing varname with the name of the variable you want to use in the header, and template name with the name of the template you created for it. Set 'Plugin is Active' to yes.

          You can now call the code from your template in any other template by using $varname or whatever you named the variable in the PHP code
          vbStartup.com: vBulletin 3.7 Styles | vBulletin Tutorials

          Comment


          • #6
            Thanks for the reply - much appreciated.

            So...if I wanted to include a file called "navbar" I would use the following code?

            Code:
            eval('$varname = navbar' . fetch_template('navbar.php') . '";'); 
            ??

            I suspect that I've misunderstood the above.

            Comment


            • #7
              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.
              vbStartup.com: vBulletin 3.7 Styles | vBulletin Tutorials

              Comment


              • #8
                Many thanks for the help - much appreciated.

                Comment


                • #9
                  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');
                  Best Regards
                  Colin Frei

                  Please don't contact me per PM.

                  Comment


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

                    Comment


                    • #11
                      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.
                      Best Regards
                      Colin Frei

                      Please don't contact me per PM.

                      Comment


                      • #12
                        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

                        Comment


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

                          Comment


                          • #14
                            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.
                            Best Regards
                            Colin Frei

                            Please don't contact me per PM.

                            Comment


                            • #15
                              Look at the below screenshot

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

                              Ah... Colin explained it before I finished the screenshot.
                              vbStartup.com: vBulletin 3.7 Styles | vBulletin Tutorials

                              Comment

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