Hi Skrol:
Im developing with tbs1.81, and didnt consider upgrading (since i've got to fix it to work on my php4.1.2-6woody3 and dunno if a newer version will work) but i've found a problem with pages and can't get rid of it (so if it can be fixed by upgrading to a newer tbs.. ill need to rewrite the code related to cloneblocks?).
The issue is:
im coding a download collection, which displays the path to current categories, all nested categories and finally the download items in the current level (these are paginated). I've took the code from the examples, with some minor changes and it works by getting just one parm from the url: the page you want to see, like (stripped template follows)
<table>
<tr>
<td width="80" valign="top">
<div align="left">Página: </div></td>
<td width="20" valign="top">
<div align="center">
<a href="download.php?id=[var.id]&par1=[pg.#]">[pg.#;block=td]</a>
<br>
[var.PaginaNum;if [val]=[pg.#];then '^' ;else '']
</div>
</td>
</tr>
</table>
|
where var.id is just the category to be listed. On the PHP side we have:
//...
if (array_key_exists("par1",$_GET)) {
$PaginaNum = $_GET["par1"] ;
} else {
$PaginaNum = 1 ;
}
$CuentaReg = -1 ;
$ElemPorPag = 4 ;
//...more code here to get the path, cats and subcats,
//and fetch properties from each file (format,size,lastchange,etc)
$CuentaReg = $TBS->MergeBlock("descargas",$descarga,"",$ElemPorPag,$PaginaNum,$CuentaReg) ;
//Calculate how many pages..
$Paginas = ceil($CuentaReg / $ElemPorPag) ;
//Replace numbers
$TBS->MergeBlock("pg","num",$Paginas) ;
|
Everithing works fine except for the par1 parameter.. if i manually change its value on the url putting something higher than the possible number of pages, it hangs ' til reaches the max_execution_time defined on php.ini. The question is where should i validate the PageNum against RecKnown/PageSize to avoid this situation?
I'm thinking of paginate many other listings with this tecnique and if my code is correct, i wish to patch tbs for future similar uses.
Best Regards