Forum Moderators: coopster
-- template code extract
<body>
{if $section eq "section_one"}
{php}
include ("html_dir/section_one.html");
{/php}
{else}
{php}
include ("html_dir/section_other.html");
{/php}
{/if}
-- end of extract --
This doesn't seems a neat way of doing this (I am new to this web development stuff) and gets quite tangled when alot of different sections are to be included.
Does anyone have experience a more elegant way of doing this sort of thing?
Thanks
How about using the variable name to get the page, if they are the same?
{php} if ($section) { $thispg="html_dir/".$section.".html"; } else { $thispg="html_dir/section_other.html"; } include $thispg; {/php} I'm not sure what your capabilities are within the template (meaning I'm not sure what the curly braces signify), but if you can read a PHP variable, you should be able to integrate it with the template.
$smarty->assign('SectionFile','section-name.html');
$smarty->display('template.tpl');
In the template itself:
{include file="html_dir/$SectionFile"}
You don't need to embed PHP into the template using {php}, just use Smarty's include function.
Hope this helps!