WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Templates, Menus & Design => Topic started by: babsy on October 27, 2008, 04:09:25 PM

Title: PHP SCRIPT in the template only works on first page
Post by: babsy 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]
Title: Re: PHP SCRIPT in the template only works on first page
Post by: ruebenwurzel 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
Title: Re: PHP SCRIPT in the template only works on first page
Post by: babsy 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");
        ?>

___________________ ____________
Title: Re: PHP SCRIPT in the template only works on first page
Post by: vyni 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