Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

2 templates?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
bobbonew
Smarty Rookie


Joined: 28 Sep 2003
Posts: 8

PostPosted: Wed Oct 08, 2003 3:45 am    Post subject: 2 templates? Reply with quote

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
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Wed Oct 08, 2003 4:21 am    Post subject: Reply with quote

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
View user's profile Send private message
bobbonew
Smarty Rookie


Joined: 28 Sep 2003
Posts: 8

PostPosted: Wed Oct 08, 2003 7:15 pm    Post subject: Reply with quote

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
View user's profile Send private message
bobbonew
Smarty Rookie


Joined: 28 Sep 2003
Posts: 8

PostPosted: Fri Oct 10, 2003 8:04 pm    Post subject: Reply with quote

Please help? It shouldn't be a major problem.
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Fri Oct 10, 2003 11:08 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP