PHP em TPL! Dúvidas!

hatelover

Power Member
Boas!

Estou a tentar incluir um codigo PHP + javascript num ficheiro tpl de header de um forum para fazer um image randomizer, so que não estou a conseguir..

Penso que ele não está a reconhecer parte do PHP e falha num if-else que tenho para lá.. Alguém tem ideias de como contornar o problema? Posso disponibilizar o código se precisarem..
 
Depende muito da construção do TPL. O mesmo pode não aceitar condigo php e teres necessidade de colocar esse código no ficheiro que usa o TPL.

Saudações
 
Boas!

Estou a tentar incluir um codigo PHP + javascript num ficheiro tpl de header de um forum para fazer um image randomizer, so que não estou a conseguir..

Penso que ele não está a reconhecer parte do PHP e falha num if-else que tenho para lá.. Alguém tem ideias de como contornar o problema? Posso disponibilizar o código se precisarem..

Era uma ajuda.. assim não é fácil ajudar..
Mas antes disse revisa se tens ";" nos locais todos.. a mim acontece frequentemente :P

cump
 
Código do TPL disse:
<?php
$path_to_images = "banners/";
$num_to_rotate = ALL;

function getJSRandomized($path, $list, $num) {
$str = '"';
mt_srand( (double)microtime() * 1000000 );
shuffle($list);
if ( $num == "ALL" ) $num = count($list);
for ($i=0; $i<$num; $i++) {
$str .= $path . $list[$i] . '", "';
}
$str = substr($str, 0, -3);
return $str;
}

function getImagesList($path) {
$ctr = 0;
if ( $img_dir = @opendir($path) ) {
while ( false !== ($img_file = readdir($img_dir)) ) {
if ( preg_match("/(\.gif|\.jpg)$/", $img_file) ) {
$images[$ctr] = $img_file;
$ctr++;
}
}
closedir($img_dir);
return $images;
} else {
return false;
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html dir="{S_CONTENT_DIRECTION}">
<head>
<meta http-equiv="Content-Type" content="text/html; charset={S_CONTENT_ENCODING}">
<meta http-equiv="Content-Style-Type" content="text/css">
<link rel="icon" href="../favicon.ico" />
<link href="templates/NoseBleed/NoseBleed.css" rel="stylesheet" type="text/css">
<script src="js/dw_rotator.js" type="text/javascript"></script>
<script src="js/dw_random.js" type="text/javascript"></script>
</head>
<body bgcolor="#FFFFFF" text="#111111" link="#9F0002" vlink="#9F0002" leftmargin="0" topmargin="0" onload="dw_Rotator.start()">

<a name="top"></a>
<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0" align="center">


<table width="780" height="100%" cellspacing="0" cellpadding="10" border="0" align="center">
<tr>
<td class="bodyline" valign="top">

<table width="717" height="231" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><a href="{U_INDEX}">
<img src="banners/default/default.jpg" border="0" alt="{L_INDEX}" vspace="1" /></a></td>
</tr>
<tr align="center">
<td>
<?php
if ( $image_list = getImagesList($path_to_images) )
{
<script type="text/javascript">
var imgList = [
<?php echo getJSRandomized($path_to_images, $image_list, $num_to_rotate); ?>
];
var rotator1 = new dw_RandRotator(30000);
rotator1.setUpImage(imgList, null, null, false);
</script>
}
else {
<script type="text/javascript">dw_Rotator.start = function() {};</script>
}
?>
</tr>
</table>
<table width="715" height="20" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><a href="{U_FAQ}" class="mainmenu">{L_FAQ}</a>&nbsp;&nbsp;<a href="{U_SEARCH}" class="mainmenu">{L_SEARCH}</a>&nbsp;&nbsp;<a href="{U_MEMBERLIST}" class="mainmenu">{L_MEMBERLIST}</a>&nbsp;&nbsp;<a href="{U_GROUP_CP}" class="mainmenu">{L_USERGROUPS}</a>&nbsp;&nbsp;<a href="{U_PROFILE}" class="mainmenu">{L_PROFILE}</a>&nbsp;&nbsp;<a href="{U_PRIVATEMSGS}" class="mainmenu">{PRIVATE_MESSAGE_INFO}</a></td><td align="right"><span class="mainmenu"><a href="{U_LOGIN_LOGOUT}" class="mainmenu">{L_LOGIN_LOGOUT}</a>
<!-- BEGIN switch_user_logged_out -->
&nbsp;&nbsp;<a href="{U_REGISTER}" class="mainmenu">{L_REGISTER}</a>
<!-- END switch_user_logged_out --></span></td>
</tr>
</table>

parte do javascript que faz o output da imagem disse:
dw_RandRotator.prototype.setUpImage = function(imgAr, w, h, bTrans) {
this.trans = bTrans;
this.ctr = Math.floor( Math.random() * imgAr.length );
var img = imgAr[ this.ctr ];
var imgStr = '<img name="' + this.name + '" src="' + this.path + img + '"';
imgStr += ( typeof w == "number") ? ' width="' + w + '"': '';
imgStr += ( typeof h == "number") ? ' height="' + h + '"': '';
imgStr += ' border="0" alt="{L_INDEX}" vspace="1" align="center">';
var str = "";
if (this.clickable) { // link it
str += '<a href="" onclick="return dw_Rotator.doClick(' + this.num + ')"';
if (this.mouseEvs) {
str += ' onmouseover="dw_Rotator.pause(' + this.num + ')"'
str += ' onmouseout="dw_Rotator.resume(' + this.num + ')"';
}
str += ' onfocus="this.blur()">' + imgStr + '</a>';
} else {
str = imgStr;
}
document.write(str); document.close();
for (var i=0; imgAr; i++) this.addImages( imgAr );


Aqui fica o código :b
 
Back
Topo