|
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 |
maspai Smarty n00b
Joined: 02 May 2015 Posts: 4
|
Posted: Sat May 02, 2015 9:32 am Post subject: Check if block content is empty |
|
|
Layout:
Code: | <div id="container">{block "main"}{/block}</div> |
View:
Code: | {block "main"}The content{/block} |
How to hide div.container when content of block "main" is empty or not passed by view - other than using {capture} in place of {block}?
If I do in layout:
Code: | <div id="container">{block "main" hide}{/block}</div> |
div.container will always be displayed.
Thanks. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Sat May 02, 2015 9:39 pm Post subject: |
|
|
Full, working code, please.
From your description, it leaves much to guess, and i'm not into guesswork. |
|
Back to top |
|
maspai Smarty n00b
Joined: 02 May 2015 Posts: 4
|
Posted: Sun May 03, 2015 4:49 am Post subject: |
|
|
I'm using Kohana framework.
My master layout:
Code: | <body><div id="container">{block "main"}{/block}</div></body> |
My view (View 1) that extends master layout:
Code: | {block "main"}Some content{/block} |
My another view (View 2) that also extends master layout, doesn't pass {block "main"}.
What I expect is:
Code: | <body><div id="container">Some content</div></body> |
|
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
|
Back to top |
|
maspai Smarty n00b
Joined: 02 May 2015 Posts: 4
|
Posted: Sun May 03, 2015 2:54 pm Post subject: |
|
|
Thanks. I didn't read the whole page. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sun May 03, 2015 11:42 pm Post subject: |
|
|
Master layout:
Code: | <body>{block "main" hide}<div id="container">{$smarty.block.child}</div>{/block}</body> |
|
|
Back to top |
|
maspai Smarty n00b
Joined: 02 May 2015 Posts: 4
|
Posted: Mon May 04, 2015 3:50 am Post subject: |
|
|
U.Tews wrote: | Master layout:
Code: | <body>{block "main" hide}<div id="container">{$smarty.block.child}</div>{/block}</body> |
|
This is better than mine. Before, I added {if} to check if {$smarty.block.child} is empty. 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
|