custom PHP
|
kruegerson
![]()
Joined: 2009-04-22
Posts: 6 |
Posted: Wed, 2009-07-08 12:52
|
|
Hi, I have a problem: I want to customize the head of my gallery and include a simple banner rotation. I have searched the forum etc. for a possibility to insert custom php code. This was my idea: But I have learned that I cannot insert custom PHP code in one of the .tpl files inside my teplates folder.. Any help is greatly appreciated, thank you .. this is the gallery where I want to place this little banner rotation: |
|


Posts: 25961
I would just edit the template file you are wanting to place the rotation code.
like:
{php} your php code goes here {/php}if you are using javascript then you have to escape smarty parsing:
{literal} <javascript> code here </script> {/literal}stuck still? post what you are trying to add.
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 6
O my .. so simple!
Thank you so much for your help!!
This is my simple little random banner generator. I just put a couple of files into a directory called 'banner' in my home directory and added the code below in my ads.tpl
If anyone is copying this, note that you have to use the physical file path on your server i.e. /usr/www/users/yourhosting/yourdir/ on some linux systems
---
{php}
$filename = array(); # initialize array
$num_files=0; # set count to 0
if($dir=@opendir ("/filepath/")) # must be local file path, not web root
{
while ($file = readdir($dir)) { # as long as files are found do the following..
# we want .php files only (excluding unix . .. files)
$dot_pos = strrpos($file,".");
$suffix = substr($file, $dot_pos);
if( $suffix == ".php")
{
$num_files++; # increase +1
$filename[] = $file; # find filename
}
}
closedir($dir);
}
srand((double)microtime()*1000000); # initialize random number
$random_file=rand(0,$num_files-1); # between 1 and total amount of files
include("/filepath/".$filename[$random_file]);
{/php}
--
Works fine for me - example
Thanks again, Dave