|
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 |
Kambaa Smarty n00b
Joined: 29 Sep 2014 Posts: 2
|
Posted: Mon Sep 29, 2014 8:06 am Post subject: How can i disregard parsing an area in the template ? |
|
|
Hello i have a question. Think of a news page of a website. At first it displays the list of all news, and if you click one of them, that news content will be displayed on the page. I thought of writing a SINGLE TEMPLATE FILE that has both page's layout. Here's an example:
Code: |
--NEWS LIST TEMPLATE START--
<ul>
<REPEATING SECTION START>
<li><a href="NEWS LINK">NEWS LABEL</a></li>
</REPEATING SECTION END>
</ul>
--NEWS LIST END--
--NEWS CONTENT TEMPLATE START--
<div>
<h3>NEWS TITLE</h3>
<p>NEWS CONTENT</p>
</div>
--NEWS CONTENT TEMPLATE END-- |
My problem is this: How can i write that if i'm at the news listing page, smarty should NOT PARSE the NEWS CONTENT AREA in the template? How can i disregard parsing an area in the template and NOT SHOW that area on the page?
Thank You,
Kambaa |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Mon Sep 29, 2014 7:03 pm Post subject: |
|
|
If you are loading everything by default, why not hide content with CSS and javascript? Then there is no page reload on the client. Otherwise if you really want to reload and have the server side handle it:
Code: | {if $page eq "news_listing"}
... put news listing content ...
{else}
... put other content ...
{/if} |
Then in the PHP code assign "page" to the page you are currently on. Something along the lines of (assuming page is passed in the url):
Code: | $smarty->assign('page', $_GET['page']); |
|
|
Back to top |
|
Kambaa Smarty n00b
Joined: 29 Sep 2014 Posts: 2
|
Posted: Mon Sep 29, 2014 9:02 pm Post subject: |
|
|
i was thinking this server side... A simple if else is really the solution... i couldn't though of that!!! i was more focused on looking for a smarty tag/method for that. Thanks.... |
|
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
|