WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Templates, Menus & Design »
  • PHP SCRIPT in the template only works on first page
  • Print
Pages: [1]   Go Down

Author Topic: PHP SCRIPT in the template only works on first page  (Read 3925 times)

Offline babsy

  • Posts: 337
PHP SCRIPT in the template only works on first page
« on: October 27, 2008, 04:09:25 PM »
Hi.. :) i have a weird problem, i have php code included on my template index file, that makes the ad´s in one of the media folders to rotate!

But the script only works on the first page.. index, an not on any other pages?

has anyone had this problem? here is the code: (see attachment)

[gelöscht durch Administrator]
Logged

Offline ruebenwurzel

  • Betatester
  • **
  • Posts: 8544
  • Gender: Male
  • Keep on Rockin
    • Familie Gallas Online
Re: PHP SCRIPT in the template only works on first page
« Reply #1 on: October 27, 2008, 05:07:33 PM »
Hello,

would be nice if you only would post the rotate script and not your whole index.php. Very hard to read trough and try to find your rotate script.

But i think the issue is the path. If make it relativ (/media/...) this only works for root directory. Add the variabel WB_URL before and it should work for subpages too.

Matthias
Logged

Offline babsy

  • Posts: 337
Re: PHP SCRIPT in the template only works on first page
« Reply #2 on: October 28, 2008, 12:29:39 PM »
ok... here is the script:
i´ve tried putting WB_URL infront, but it doesn´t seem to work, any ide, where to put it?
___________________ ___________
    <?php
        //echo "HEHEHEHHEHE";
        $dirPath = "media/rotera_lysing/";

        $fileArray = array();

        if ($handle = opendir($dirPath))
        {
             while (false !== ($file = readdir($handle)))
             {
                if ($file != "." && $file != "..")
                {
                   $chunks = explode(".",$file);
                   if (count($chunks)>1)
                   {
                    if (in_array(strtolower($chunks[1]),array("gif","jpg","jpeg","png","swf")))
                    {
                        array_push($fileArray,$file);
                    }
                   }
                }
             }

             closedir($handle);
        }

        for ($i=0; $i<5; $i++)
        {
            shuffle($fileArray);
        }

        // display max number of advertisements
        $maxNumber = 15;

        foreach ($fileArray as $number => $file)
        {
            if ($number < $maxNumber)
            {
                $chunks = explode(".",$file);
                if ($chunks[1] == "swf")
                {
                    //echo "No: ".$number." - ".$file."<br />";
                    echo "<object codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width='130' height='70'>";
                    echo "<param name='loop' value='true' />";
                    echo "<param name='movie' value='".WB_URL."/".$dirPath.$file."' />";
                    echo "<param name='quality' value='best' />";
                    echo "<param name='play' value='true' />";
                    echo "<embed pluginspage='http://www.macromedia.com/go/getflashplayer' src='".WB_URL."/".$dirPath.$file."' type='application/x-shockwave-flash' width='130' height='70' quality='best' play='true' loop='true'></embed>";
                    echo "</object>";

                    //classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
                }
                else
                {
                    //$newFile = str_replace("---","www",$chunks[0]);
                    if (stripos($chunks[0],"-p-") === false)
                    {
                        echo "<img vspace='5' border='0' src='".WB_URL."/".$dirPath.$file."' width='130' /><br />";
                    }
                    else
                    {
                        $newFile = str_replace("-p-",".",$chunks[0]);
                        $newFile = str_replace("-s-","/",$newFile);

                        echo "<a href='http://".$newFile."' target='_blank'><img vspace='5' border='0' src='".WB_URL."/".$dirPath.$file."' width='130' /></a><br />";
                    }
                }
            }
        }

        //include (WB_URL."/pages/blocks/lysingar.php");
        ?>

___________________ ____________
Logged

vyni

  • Guest
Re: PHP SCRIPT in the template only works on first page
« Reply #3 on: October 29, 2008, 08:04:22 AM »
Hi,

I don´t know, but my first idea is Your third line.

In the first page the browser shows in the adress line: http://your.dom.ain  - no more, no less (now the script could find mdia/rotera.... as subfolder)
As soon You choose annother page, the browser shows http://your.dom.ain/pages/whatever.php (now there is no subfolder media to find)

So change the path either to Your domain - http://your.dom.ain/media/rotera... or try $dir = WB_PATH."media/rotera...." annother could be $dir = MEDIA_DIRECTORY."/rotera...."

As I said - I don´t know. But it is propably a path-problem.

regards from Himberg, next to Vienna
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Templates, Menus & Design »
  • PHP SCRIPT in the template only works on first page
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2