How do I add PHP includes?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • I, Brian
    Senior Member
    • Feb 2003
    • 400
    • 3.6.x

    How do I add PHP includes?

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

  • MrVain
    New Member
    • Oct 2005
    • 27
    • 3.5.x

    #2
    to pages or the headerinclude thingy?

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

    Comment

    • conqsoft
      Senior Member
      • Jul 2003
      • 3803
      • 3.6.x

      #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

      • I, Brian
        Senior Member
        • Feb 2003
        • 400
        • 3.6.x

        #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

        • vbStartup
          Senior Member
          • Oct 2005
          • 114
          • 3.6.x

          #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

          • I, Brian
            Senior Member
            • Feb 2003
            • 400
            • 3.6.x

            #6
            Thanks for the reply - much appreciated.

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

            Code:
            [COLOR=Black][COLOR=#000000][COLOR=#007700]eval([/COLOR][COLOR=#dd0000]'$varname = navbar' [/COLOR][COLOR=#007700]. [/COLOR][COLOR=#0000bb]fetch_template[/COLOR][COLOR=#007700]([/COLOR][COLOR=#dd0000]'navbar.php'[/COLOR][COLOR=#007700]) . [/COLOR][COLOR=#dd0000]'";'[/COLOR][COLOR=#007700]); [/COLOR][/COLOR][/COLOR]
            ??

            I suspect that I've misunderstood the above.

            Comment

            • vbStartup
              Senior Member
              • Oct 2005
              • 114
              • 3.6.x

              #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

              • I, Brian
                Senior Member
                • Feb 2003
                • 400
                • 3.6.x

                #8
                Many thanks for the help - much appreciated.

                Comment

                • Colin F
                  Senior Member
                  • May 2004
                  • 17689

                  #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

                  • I, Brian
                    Senior Member
                    • Feb 2003
                    • 400
                    • 3.6.x

                    #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

                    • Colin F
                      Senior Member
                      • May 2004
                      • 17689

                      #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

                      • Chroder
                        Senior Member
                        • Dec 2002
                        • 1449

                        #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

                        • I, Brian
                          Senior Member
                          • Feb 2003
                          • 400
                          • 3.6.x

                          #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

                          • Colin F
                            Senior Member
                            • May 2004
                            • 17689

                            #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

                            • vbStartup
                              Senior Member
                              • Oct 2005
                              • 114
                              • 3.6.x

                              #15
                              Look at the below screenshot



                              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...