[Solved]Trying to Hide Empty Content Blocks

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
jasnick
Power Poster
Power Poster
Posts: 695
Joined: Sat Jan 15, 2011 8:36 am

Re: Trying to Hide Empty Content Blocks

Post 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>
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: Trying to Hide Empty Content Blocks

Post 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.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Trying to Hide Empty Content Blocks

Post 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...
jasnick
Power Poster
Power Poster
Posts: 695
Joined: Sat Jan 15, 2011 8:36 am

Re: Trying to Hide Empty Content Blocks

Post 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.
jasnick
Power Poster
Power Poster
Posts: 695
Joined: Sat Jan 15, 2011 8:36 am

Re: Trying to Hide Empty Content Blocks

Post 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.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: [Solved]Trying to Hide Empty Content Blocks

Post 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}
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
jasnick
Power Poster
Power Poster
Posts: 695
Joined: Sat Jan 15, 2011 8:36 am

Re: [Solved]Trying to Hide Empty Content Blocks

Post by jasnick »

Thanks Calguy1000 - I'll try that too!
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: [Solved]Trying to Hide Empty Content Blocks

Post 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]
Post Reply

Return to “Layout and Design (CSS & HTML)”