Page 2 of 2

Re: Trying to Hide Empty Content Blocks

Posted: Thu Apr 25, 2013 11:45 am
by jasnick
I added <h1>Test</h1> to the next content block then removed it. Then had a look at Page Source as you suggested: the tag was still there although the actual word 'test' was gone.


<div class="box">

<h1> </h1>
</div>

Re: Trying to Hide Empty Content Blocks

Posted: Thu Apr 25, 2013 12:09 pm
by velden
Obviously the variable contains '<h1></h1>' which is not an empty string.

So now you have to check why that content stays in there.

You are aware of the 'view html' checkbox below the wysiwyg editor while changing page content? If checked I expect the '<h1></h1>' to be there.

Choose select all (ctrl-a) and delete all content. Mind that a single space or enter is content too.

Re: Trying to Hide Empty Content Blocks

Posted: Thu Apr 25, 2013 9:29 pm
by Dr.CSS
I always use...

{content block='newsblock' assign='test'}
{if !empty($test)}
<div class="content">
{$test}
</div>
{/if}

Test if it's not empty, if not show it...

Re: Trying to Hide Empty Content Blocks

Posted: Fri Apr 26, 2013 12:19 am
by jasnick
velden wrote:You are aware of the 'view html' checkbox below the wysiwyg editor while changing page content? If checked I expect the '<h1></h1>' to be there.
Sorry if I haven't made myself clear.Yes I am aware of the html checkbox - that is what I have been using myself to remove the left-over tags. it is just that I don't want the editor to use it.
velden wrote:Choose select all (ctrl-a) and delete all content. Mind that a single space or enter is content too.
I wonder if that is the problem. Yes, the text and image are indented and spaced. I'll check it when I start work this morning.

Thanks Dr.CSS - I'll also check that out this morning.

Re: Trying to Hide Empty Content Blocks

Posted: Fri Apr 26, 2013 1:14 am
by jasnick
velden wrote:Choose select all (ctrl-a) and delete all content. Mind that a single space or enter is content too.
Yes - that was it! I was deleting them in the editing box one at a time (text and image) instead of selecting both together which of course incorporated the indenting space and the line space.

I won't forget THAT in a hurry! :-[

Thank you so much for your patience, Velden and for the input from Rolf, Paul, Rotezecke and Dr.CSS.

Re: [Solved]Trying to Hide Empty Content Blocks

Posted: Fri Apr 26, 2013 1:33 am
by calguy1000
something like this should work:

Code: Select all

{content assign='foo'}
{assign var='foo' value=$foo|strip_tags|strip}
{if $foo != ''}<div id="foo">{$foo}</div>{/if}

Re: [Solved]Trying to Hide Empty Content Blocks

Posted: Fri Apr 26, 2013 2:09 am
by jasnick
Thanks Calguy1000 - I'll try that too!

Re: [Solved]Trying to Hide Empty Content Blocks

Posted: Fri Apr 26, 2013 6:18 am
by velden
calguy1000 wrote:something like this should work:

Code: Select all

{content assign='foo'}
{assign var='foo' value=$foo|strip_tags|strip}
{if $foo != ''}<div id="foo">{$foo}</div>{/if}
But this will give you unformatted text when you DO want content, doesn't it?

What about this:

Code: Select all

{content assign='foo'}
{assign var='foo_stripped' value=$foo|strip_tags|strip}
{if $foo_stripped != ''}<div id="foo">{$foo}</div>{/if}
[/quote]