473,398 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

smarty simple question?

i'm newcomer in using smarty and i have problem like this:
i want to have one template file (e.g. index.tpl) in this file section
which use variable {$content}.
and two files *.php which are using the same template index.tpl and
only change the content.

for example:
/*index.php*/
$smarty = new MySmarty();
$smarty->assign('content','INDEX');
/*about.php*/
$smarty=new MySmarty();
$smarty->assign('content','ABOUT');

how to do this, because this way it doesn't work?

Jun 7 '07 #1
2 2050
On Jun 7, 5:52 am, Gene <ox.g...@wp.plwrote:
i'm newcomer in using smarty and i have problem like this:
i want to have one template file (e.g. index.tpl) in this file section
which use variable {$content}.
and two files *.php which are using the same template index.tpl and
only change the content.

for example:
/*index.php*/
$smarty = new MySmarty();
$smarty->assign('content','INDEX');
/*about.php*/
$smarty=new MySmarty();
$smarty->assign('content','ABOUT');

how to do this, because this way it doesn't work?
give your second inherited MySmarty() object a different reference
name:
....
/*about.php*/
$smarty2 = new MySmarty();
$smarty2->assign('content','ABOUT');

hth,

gk

Jun 7 '07 #2
Gene wrote:
i'm newcomer in using smarty and i have problem like this:
i want to have one template file (e.g. index.tpl) in this file section
which use variable {$content}.
and two files *.php which are using the same template index.tpl and
only change the content.

for example:
/*index.php*/
$smarty = new MySmarty();
$smarty->assign('content','INDEX');
/*about.php*/
$smarty=new MySmarty();
$smarty->assign('content','ABOUT');

how to do this, because this way it doesn't work?

You can include php files in smarty
(http://smarty.php.net/manual/en/lang...nclude.php.php)

{if $content == "INDEX"}
{include_php file="index.php"}
{elseif $content == "ABOUT"}
{include_php file="about.php"}
{/if

The much better way is to include also templates for different content
with include (http://smarty.php.net/manual/en/lang...on.include.php)

{if $content == "INDEX"}
{include file="index.tpl"}
{elseif $content == "ABOUT"}
{include file="about.tpl"}
{/if
Jun 11 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Daan | last post by:
Hello all, I'm having a little problem with Smarty. Getting it to work in a simple case went fine, but now I have the following situation: / /smarty /templates template.tpl /templates_c
1
by: Richard | last post by:
I need help. I have a smarty based program that I am modifying. I have a smarty template file that consists of smarty and HTML. I need to integrate some PHP database calls into it. My problem...
2
by: Mike | last post by:
I am sure that I am making a simple boneheaded mistake and I would appreciate your help in spotting in. I have just installed apache_2.0.53-win32-x86-no_ssl.exe php-5.0.3-Win32.zip...
1
by: DJ Majestik | last post by:
OK, I am new to the whole PEAR/Smarty templating thing. I am trying to setup my directory structure correctly. If someone could weigh in and see if I have this setup "right", I would appreciate it....
2
by: M | last post by:
Hi Folks, I am trying to install Smarty using PHP 5 on a Windows XP PC using IIS v6 The following PHP File: <!doctype html public "-//W3C//DTD HTML 4.0 //EN"> <html> <head>
2
by: Freebird | last post by:
Hello you all, =] I've a smarty var, like this: {$var} that is equal to: ttttttttttttt|zzzzzzzzzzzz It can be any size, the important is that they are separated by the '|' How do I...
0
by: Conrad | last post by:
Hi, I'm very new to Smarty Template Engine and I'm using PHP 5.0.4 on the Windows XP Professional platform and I have the following question: When I change the 7th line of the script to use a...
7
by: diane100 | last post by:
Hi I am new to PHP and Smarty (I know only very basic things) and I need help with a warning message I get when I call a page in a browser. I purchased some software from a company who are no...
1
by: empiresolutions | last post by:
i have what may be a very simple question for someone who has worked with X-Cart or Smarty. I am adding a rollover image next to the category names in the main navigation. The following is my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.