Welcome to Dream.In.Code
Become a PHP Expert!

Join 150,166 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,315 people online right now. Registration is fast and FREE... Join Now!




php templates

 
Reply to this topicStart new topic

php templates, unable to load template file from php - Urgent

baachitech
26 Aug, 2008 - 10:04 AM
Post #1

New D.I.C Head
*

Joined: 26 Aug, 2008
Posts: 6

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.10

the 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.10

It'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


User is offlineProfile CardPM
+Quote Post

jonesa01
RE: Php Templates
28 Aug, 2008 - 08:31 AM
Post #2

New D.I.C Head
Group Icon

Joined: 18 Feb, 2007
Posts: 39


Dream Kudos: 25
My Contributions
Hi,

Can you post the code for template.php, so I can piece together the code, so it will be easier to see what is wrong.

Adam
User is offlineProfile CardPM
+Quote Post

baachitech
RE: Php Templates
29 Aug, 2008 - 10:14 AM
Post #3

New D.I.C Head
*

Joined: 26 Aug, 2008
Posts: 6

QUOTE(jonesa01 @ 28 Aug, 2008 - 09:31 AM) *

Hi,

Can you post the code for template.php, so I can piece together the code, so it will be easier to see what is wrong.

Adam


Hi Adam, Thanq for spending time. Actually the entire site buit by some one and they encripted the source with ioncube. we bought it from that company. they given all the source code except the main index.php. they said, they don't have source for index.php.

one month back i started to learn PHP, and now i able to create the main index.php file to use the templates.

I findout that, I forgot to include one of the include file. that is why the template display nothing. now it is ok.

ThanQ verymuch for spending your valuable time.

Take Kare
Sudha

User is offlineProfile CardPM
+Quote Post

jonesa01
RE: Php Templates
31 Aug, 2008 - 12:14 AM
Post #4

New D.I.C Head
Group Icon

Joined: 18 Feb, 2007
Posts: 39


Dream Kudos: 25
My Contributions
QUOTE(baachitech @ 29 Aug, 2008 - 11:14 AM) *

QUOTE(jonesa01 @ 28 Aug, 2008 - 09:31 AM) *

Hi,

Can you post the code for template.php, so I can piece together the code, so it will be easier to see what is wrong.

Adam


Hi Adam, Thanq for spending time. Actually the entire site buit by some one and they encripted the source with ioncube. we bought it from that company. they given all the source code except the main index.php. they said, they don't have source for index.php.

one month back i started to learn PHP, and now i able to create the main index.php file to use the templates.

I findout that, I forgot to include one of the include file. that is why the template display nothing. now it is ok.

ThanQ verymuch for spending your valuable time.

Take Kare
Sudha


No problem, in future I would suggest that you spend a bit more, and get them not to encrypt it. Its just a way to get more money from you sad.gif.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 02:57AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month