Reply to Re: smarty simple question?

Your name:

Reply:


Posted by Joe Scylla on 06/11/07 08:06

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/language.function.include.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/language.function.include.php)

{if $content == "INDEX"}
{include file="index.tpl"}
{elseif $content == "ABOUT"}
{include file="about.tpl"}
{/if

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация