Announcement

Collapse
No announcement yet.

PHP Code within templates? How?

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

  • PHP Code within templates? How?

    I am trying to execute some php code within the fivelinks template, but when I add the code, it shows up in the source. If I leave for the < > tags, then it shows on the page.

    How can I get the php code to parse there?

    Thanks

    CDitty


  • #2
    you can't parse code from the templates.

    Comment


    • #3
      Bummer.

      Any idea then on how I can get my parsed code into that spot?

      Comment


      • #4
        Put it in the phpinclude template and then reference the variables from your other templates. Any code your put in phpinclude will be executed on every page so make sure it isn't resource intensive.

        Comment


        • #5
          Can you be a little more specific? A quick search doesn't find any phpinclude template.

          Comment


          • #6
            phpinclude is only in version 2.0

            Comment


            • #7
              I was afraid of that. Any other suggestions?

              Comment


              • #8
                Put your code into global.php and then reference the variables as needed.
                Translations provided by Google.

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

                Comment


                • #9
                  This won't work either. If I can't parse php code within the templates, putting the code I need parse in the global.php file only executes it. I still can't reference it from the template files.

                  Correct?

                  Comment


                  • #10
                    If you stick the parsed code into variables you can reference it anywhere. That is what all the $words in the templates are... PHP Variables.
                    Translations provided by Google.

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

                    Comment


                    • #11
                      I know what variables are.

                      I tried your suggestion and the code appears at the top of the page and not in the template.

                      Comment


                      • #12
                        I'm guessing you're printing your code out directly, so we can only help you if you show us what you're trying to do.

                        Comment


                        • #13
                          Not really much to show. Just trying to put an ad banner on the fivelinks template.

                          Using WebAdverts for banner script and calling it with virtual("/cgi-local/ad_site.pl")

                          Don't know what else to say.

                          Comment


                          • #14
                            virtual() outputs directly. You need to put it into a variable.

                            One way is to do this (PHP4 only):
                            Code:
                            ob_start();
                            virtual("/cgi-local/ad_site.pl");
                            $var = ob_get_contents();
                            ob_end_clean();
                            You can then reference $var.

                            Comment


                            • #15
                              Just tried that and it still spits it out at the top of the page. Before it gets to the variable.

                              Comment

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