|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
bobbonew Smarty Rookie
Joined: 28 Sep 2003 Posts: 8
|
Posted: Wed Oct 08, 2003 3:45 am Post subject: 2 templates? |
|
|
I have two templates with each having their own variables (but not named the same). So how come I can't do this?
$smarty = new Smarty;
$smarty->assign('access_to', $access_to);
$smarty->display('index.tpl');
$smarty = new Smarty;
$smarty->assign('site_administration_nav', $site_administration_nav);
$smarty->display('main_body.tpl');
And this code is from my index.php page hehe. What i'm trying to do is first have the template that doesn't change (navigation template) and then have the body (dynamic) template come after that. |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Wed Oct 08, 2003 4:21 am Post subject: |
|
|
No need to create multiple instances of $smarty. If you remove the second "$smarty = new Smarty;" it should work fine. On the other hand, what you probably want is something like this:
[php:1:758e24eeba]<?php
$smarty = new Smarty;
$smarty->assign('access_to', $access_to);
$smarty->assign('site_administration_nav', $site_administration_nav);
$smarty->display('main.tpl');
?>[/php:1:758e24eeba]
main.tpl
Code: | {include file=index.tpl access_to=$access_to}
{include file=main_body.tpl site_administration_nav=$site_administration_nav} |
|
|
Back to top |
|
bobbonew Smarty Rookie
Joined: 28 Sep 2003 Posts: 8
|
Posted: Wed Oct 08, 2003 7:15 pm Post subject: |
|
|
Nah I dont like that method, it'll be the index.php determining what tpl to be included into the navigation tpl.
I did this code
[php:1:e002d02578]<?php
$smarty = new Smarty;
$smarty->assign('access_to', $access_to);
$smarty->display('index.tpl');
$smarty->assign('site_administration_nav', $site_administration_nav);
$smarty->display('main_body.tpl');
?>[/php:1:e002d02578]
And got this error
Code: | Warning: Smarty error: problem creating directory "templates_c/%%128/%%1287247392" in /home/newbobbo/WEB-INF/lib/Smarty.class.php on line 1042
Warning: Smarty error: problem writing temporary file 'templates_c/%%128/%%1287247392/3f846132b23ab' in /home/newbobbo/WEB-INF/lib/Smarty.class.php on line 1042
Warning: touch(): Unable to create file templates_c/%%128/%%1287247392/main_body.tpl.php because No such file or directory in /home/newbobbo/WEB-INF/lib/Smarty.class.php on line 1575
Warning: fetch(templates_c/%%128/%%1287247392/main_body.tpl.php): failed to open stream: No such file or directory in /home/newbobbo/WEB-INF/lib/Smarty.class.php on line 1158
Warning: fetch(): Failed opening 'templates_c/%%128/%%1287247392/main_body.tpl.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/newbobbo/WEB-INF/lib/Smarty.class.php on line 1158 |
And I have it all installed correctly and the correct paths set as it worked before when I only had one template. |
|
Back to top |
|
bobbonew Smarty Rookie
Joined: 28 Sep 2003 Posts: 8
|
Posted: Fri Oct 10, 2003 8:04 pm Post subject: |
|
|
Please help? It shouldn't be a major problem. |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Fri Oct 10, 2003 11:08 pm Post subject: |
|
|
Well it sure looks like you don't have your configuration setup properly. Check again.
I'm not sure why you didn't like my last suggestion. Indeed, it is index.php which is deciding which templates to include, but the actual inclusion is done dynamically by the template.
Anyways, good luck. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|