Announcement

Collapse
No announcement yet.

execute php code in the template header?

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

  • execute php code in the template header?

    I'm sure this gets asked a zillion times but what method do you go about using to get my custom PHP code to be displayed in the header template? I know you have to put it somewhere then call the variables through the template. Is there any tutorial or someone willing to share some knowledge, or help me search the forums better ( i couldnt find it). Thanks

  • #2
    You can add custom php to the hooks,

    For your needs the global_start hook is what you want to work with.

    Comment


    • #3
      still confuzing for me.. do I just put the code in the plugin, then put the end result variables in the templates?

      Comment


      • #4
        Maybe if I give full details someone could help me write a small plugin for this.. I am only experienced with vbulletin for half a day.

        Here is the original script I use on my site to query a shoutcast server:

        At the top
        Code:
        <?php
                include ("/home/eternalb/public_html/php/status/scastxml.php");
        ?>
        this includes the shoutcast xml stats parsed down to variables already for me

        This is the php code inside the template I had:

        Code:
                  <?php
                  if ($reportedlisteners==1){ $totallisteners = 'listener';  }  else { $totallisteners = 'listeners'; }
                if ($connected==1){
                   echo "Now playing: ";    //server is on 
                   ?>
                <a href="javascript:void(window.open('http://www.eternalbeats.net/listen.php', 'stream2', 'width=323,height=162,left=0,top=0, location=no, menubar=no, status=no, toolbar=no, scrollbars=no, resizable=no','replace=yes'))">
                <?php
                echo "$servertitle - $songtitle</a> - $reportedlisteners $totallisteners tuned in!";    //server is on 
                }
                if ($connected==0){
                echo "<font size='1'><b>Eternal Beats radio is currently offline.  Please check the <a href='/broadcasts/events.php?show=details'>schedule for upcoming shows</a>.  Head over to the <a href='/forums/dload.php'>audio section</a> to download some audio goodies!</b></font>";    //server is off
                }
        
            ?>
        It's probably not the most effecient code either cause I am a noob lol. Appredicate any feedback on this.

        Here is a live working demonstration http://www.eternalbeats.net/home.php

        And I need it in the same place here http://www.eternalbeats.net/vb/index.php

        Comment


        • #5
          well I figured it out, 3.5 is the win, easy, dang!

          Comment


          • #6
            RabidKevin, just sent you a PM....

            Comment


            • #7
              So what is the way to do it? My users are used to have latest threads on the top of all forum pages. Before I did this with including lastpost3.php. I understand that I still can is phpinclude, but with using a hook. So how do I do it exactly? Thank you very much in advance.
              Boris Lifanovsky; administrator of the biggest Russian classical music forum

              Lifanovsky.com | ForumKlassika.Ru

              Comment


              • #8
                Try asking for help over at vBulletin.org I'm positive someone will help.

                Comment

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