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

Load smarty class into another's div

 
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 -> Smarty 3
View previous topic :: View next topic  
Author Message
sidani
Smarty n00b


Joined: 28 Jun 2011
Posts: 3

PostPosted: Tue Jun 28, 2011 11:38 pm    Post subject: Load smarty class into another's div Reply with quote

Hi, i'm new in smarty3, and i'm developing a social site but i had an issue!
My problem is:

I have a main template file, that contains the header and the basics with a empty content div in it, i load the content via ajax, that's cool works fine!
But when the user disable javascript in his/her browser, i'm redirectim him/her to 'mysite.com/index.php?no_script', i handle it, and here is my problem:

Is it possible to make 2 smarty classes, and load one of them into the another's div? I mean:

main.tpl
Code:
<div class="head">....</div><div class="content"></div><div class="foot"></div>


for example: news.tpl
Code:
<span>News</span><br><h1>No News</h1>


So is it possible to assign the news.tpl into the main.tpl's content classed div?
Back to top
View user's profile Send private message
sidani
Smarty n00b


Joined: 28 Jun 2011
Posts: 3

PostPosted: Tue Jun 28, 2011 11:43 pm    Post subject: Reply with quote

For save: I didn't mean that i'd like to 'include' it, i'd like to use something like that:
Code:
$smarty_main->loadContent($smarty_page, "[div:content]");

For the multy usement! Because if i include it, it will be dislayed when the javascript is enable too, and if there is any chance or solution i'd not like to have 2 of each pages[because of design and etc updates]
Back to top
View user's profile Send private message
rodneyrehm
Administrator


Joined: 30 Mar 2007
Posts: 674
Location: Germany, border to Switzerland

PostPosted: Wed Jun 29, 2011 7:56 am    Post subject: Reply with quote

You have multiple options here.

1) treat content and framework (header, footer, …) seperately
Code:
$smarty->display('header.tpl');
$smarty->display('content.tpl');
$smarty->display('footer.tpl');


2) assign content to the framework
Quote:
$data = $content = $smarty->fetch('content.tpl');
$smarty->assign('content', $content);
$smarty->display('framework.tpl')


3) treat content.tpl as your central point of entry and have the template decide if the framework is to be included or not
Code:
$smarty->assign('is_ajax', false);
$smarty->display('content.tpl', $distinguish_caches_somehow);
and
Code:
{if !$is_ajax}
  {include file="header.tpl"}
{/if}
your content stuff
{if !$is_ajax}
  {include file="footer.tpl"}
{/if}


and probably some more… I went with something similar to option 3 back in the days…
Back to top
View user's profile Send private message Visit poster's website
sidani
Smarty n00b


Joined: 28 Jun 2011
Posts: 3

PostPosted: Wed Jun 29, 2011 9:23 am    Post subject: Reply with quote

Thank you Very Happy Probably i will use the 2nd ;D
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 -> Smarty 3 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