hide all block when no content [solved]

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"
Locked
cadbury

hide all block when no content [solved]

Post by cadbury »

Hi all,

i've two main block on my pages, and the second block is not always filled, it can be empty.
the block2 is defined like that :

Code: Select all

<div class="shadow">
      <div class="contentbox">
        <div class="title">
         <h2>{content block='block2title' oneline='true'}</h2>
       </div>      
      <div class="content">        
       {content block='block2'}
       </div>
     </div>
  </div>
so when the content and title is empty, the box with shadows is displayed anyway.
i'd like to know if this is possible to avoid displaying this if the content is empty, like in spip, a bit like that :

Code: Select all

{ if $idontknowwhat != '' }
<div class="shadow">
      <div class="contentbox">
        <div class="title">
         <h2>{content block='block2title' oneline='true'}</h2>
       </div>      
      <div class="content">        
       {content block='block2'}
       </div>
     </div>
  </div>
{/if}
but working :)
Last edited by cadbury on Mon Jan 22, 2007 12:00 am, edited 1 time in total.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: hide all block when no content

Post by calguy1000 »

try
{capture assign="testvar"}{content block="whatever"}{/capture}
{if isset($testvar)}{$testvar}{/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.
cadbury

Re: hide all block when no content

Post by cadbury »

you're the man!
that work great :

Code: Select all

{capture assign="testvar"}{content block='block1'}{/capture}
{if isset($testvar) && $testvar != '' }
<div class="shadow">
      <div class="contentbox">
        <div class="title">
         <h2>{content block='block1title' oneline='true'}</h2>
       </div>      
      <div class="content">        
       {$testvar}
       </div>
     </div>
  </div>
{/if}
thanks a lot
Locked

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