Hi Friends, I am new to PHP. I want use php templates in my site.
my directory structure as follows:
note: all script files stored in
sources folder.
all template files stored in
templates folder.
/index.php
/sources/details.php
/templates/details.tpl
Now, I am sending parameters to index.php like..
http://localhost/index.php?page=details.view.10the code for index.php as follows:
CODE
<?php
$src_path = "sources/";
$tpl_path = "templates/";
$ls = $_GET['page'];
// first parameter is the page name
// second param is action type
// third param is product id/navigation page #
list($p1, $p2, $p3) = split('[.]', $ls);
if ($p1=="details")
{ include("sources/details.php?id=".$p3);}
else
{ // display some other file;}
?>
code for details.php file:
CODE
<?php
// get some data from database
// included template.php file
$template = new Template;
$template->set_file('main', 'templates/details.tpl');
$template->set_var("PAGETITLE", "Description for Page Title");
$details= GetDetails($propid);
$template->set_var("ADDRESS",$details['address']);
$template->set_var("CITY",$details['cityname']);
$template->pparse('out', 'main');
?>
the details.tpl file:
CODE
<html>
<head><title>{PAGETITLE}</title></head>
<body>
Customer Address: {ADDRESS} <BR>
Customer City: {CITY}
</body>
</html>
Now, when use
http://localhost/index.php?page=details.view.10It'll excute details.php file but it won't display the details.tpl file in browser.
and also i need to know how to set source and templates path to them.
Please help. ThanQ for you help
Take kare
Sudha