View Full Version : php includes in tpl files?
toolman
06-18-2006, 10:57 PM
Hi,
When I try to use php in a php file that is included in a tpl file, it doesnt work. Any ideas why?
to use php in a .tpl
{php}
your php code goes here
{/php}
to add/include a .php file to a .tpl
{php} include ('yourfile.php'); {/php}
toolman
06-18-2006, 11:10 PM
I can include the php file in the .tpl file.. that works fine. It only contains html in the php file, but when i use actual php in that php file, the php doesnt show up.
you have to assign any variables that you are going to use outside of the scope of the php code encased in the {php} {/php}
for example, in your main.tpl, see where and how the Category rows are being assembled?
{* Calculate the number of categories per row *}
{php}
$this->assign('cats_per_col', ceil(count($this->get_template_vars('categs')) / CATS_PER_ROW));
{/php}
toolman
06-19-2006, 12:23 AM
got it working! many thanks!
vBulletin® v3.8.0, Copyright ©2000-2012, Jelsoft Enterprises Ltd.