Page 1 of 1

PHP newbie

Posted: Thu May 12, 2005 9:21 am
by musanka
Jcart | Please review :arrow: Posting Code in the Forums

I'm a newbe and I try to use Smarty.
I cann't find out how to display a template in the page contents cell.
Here is my code for index.php:

Code: Select all

<?php
require_once 'include/app_top.php';

$page = new Page();
$pageContentsCell = &quote;first_page_contents.tpl&quote;;
$page->assign('Links', 
	array('about' => 'templates/about_us.tpl', 'info' => 'templates/info.tpl'));
if (isset($Linksї'about']))
{
	$pageContentsCell = &quote;templates/about_us.tpl&quote;;
}
$page->assign(&quote;pageContentsCell&quote;, $pageContentsCell);
$page->display('index.tpl');
?>

Code: Select all

{* smarty *} 
{config_load file=&quote;site.conf&quote;} 
<!DOCTYPE html PUBLIC &quote;-//W3C//DTD XHTML 1.0 Transitional//EN&quote; 
    &quote;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quote;> 
<html xmlns=&quote;http://www.w3.org/1999/xhtml&quote; xml:lang=&quote;en&quote; lang=&quote;en&quote;> 
<head> 
<link href=&quote;style.css&quote; rel=&quote;stylesheet&quote; type=&quote;text/css&quote; /> 
  <title>{#sitetitle#}</title> 
</head> 
<body bgcolor=&quote;#FFFFCC&quote;> 
     {include file=&quote;header.tpl&quote;} 
<table cellspacing=&quote;0&quote; cellpadding=&quote;0&quote;  width=&quote;760&quote; height=&quote;100%&quote; border=&quote;1&quote; align=&quote;center&quote;> 
<tr> 
    <td valign=&quote;top&quote; > 
     {include file=&quote;navigation.tpl&quote;}  </td> 
    <td> 
     {include file=&quote;$pageContentsCell&quote;} 
    </td> 
</tr> 
</table> 
</body> 
</html>

Code: Select all

{* navigation.tpl *}
      <link href=&quote;style.css&quote; rel=&quote;stylesheet&quote; type=&quote;text/css&quote; />
<script src=&quote;listmenu.js&quote; type=&quote;text/javascript&quote;></script>
<ul class=&quote;treemenu&quote;>
	</br>
    	<li><a href=&quote;&quote;>Home</a></li>
	<li class=&quote;treenode&quote;>
		<a href=&quote;&quote;>info</a>
		<ul>
			<li><a href=&quote;{$Links.about}&quote;>about</a></li>
			<li><a href=&quote;&quote;>List Item</a></li>
			<li><a href=&quote;&quote;>List Item</a></li>
			<li><a href=&quote;&quote;>List Item</a></li>
		</ul>
	</li>
when I try to open "about"(about_us.tpl) I get just html code of the template. It isn't displayed in the page contents cell as desired.
I'm not sure if I'm on the right track. Can anybody explain how this problem should be solved. And is there a way to make is simple, so I dont' have to call $pageContentsCell for all templates, like here $pageContentsCell = "templates/about_us.tpl";
Pelase help me :cry: