HTML Template IT - creating an pageindex
| From: | Johannes Lerch | Date: | Mon, 20 Sep 2004 12:43:36 +0000 |
| Subject: | HTML Template IT - creating an pageindex | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-14567@lists.php.net to get a copy of this message | ||
Hi, there!
Don't know if its the right sport but i hope so.*
heres my problem:
i wanted to create an pageindex using templates, and at the current
project i user HTML Template IT
my template-file looks like this:
-----
Code:
<!-- BEGIN currblock -->
>{currpage}
<!-- END currblock -->
<!-- BEGIN linkblock -->
><a href="news.php?page={gotopage}">{gotopage_display}</a>
<!-- END linkblock -->
----
currblock shell display the current page, without a link to it, so the
user can see at first sight where he is. linkblock links to the according
page.
in my php file the code to handle the template looks like this:
----
Code:
for($i=0; $i<$pages; $i++)
{
if($i == $page)
{
$page_tpl->setCurrentBlock("currblock");
$page_tpl->setVariable("currpage",($i+1));
$page_tpl->parseCurrentBlock();
}
else
{
$page_tpl->setCurrentBlock("linkblock");
$page_tpl->setVariable("gotopage",$i);
$page_tpl->setVariable("gotopage_display",($i+1));
$page_tpl->parseCurrentBlock();
}
}
----
the intendent behaviour is, asuming the currently displayed page is 3, and
there are a total of 5 pages:
link to 1 > link to 2 > 3 > link to 4 > link to 5
but the output of the template looks like this:
3 > link to 1 > link to 2 > link to 4 > link to 5
this is kind of bad.
an idea of myself was to get() the block after parsing him (after the
parseCurrentBlock() ) command and concatinate the result to a string, but
even worse, following output was coming out:
1 > 2 > 1 > 2 > 3 > 1 > 2 > 3 > 4 > 1 > 2 > 3 > 4 > 5
so, does someone know how to solve this problem
kind regards, johannes lerch
johannes.lerch@reflex.at
www.johanneslerch.at.tf
*: i came here through tiping 'pear support forum' into google... no such
thing came up, instead i followed the link to php-freaks, where they say
you get support on this list (
http://www.phpfreaks.com/pear_manual/page/support.html
)