Page 1 of 1

hide all block when no content [solved]

Posted: Sat Jan 20, 2007 12:25 am
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 :)

Re: hide all block when no content

Posted: Sat Jan 20, 2007 1:24 am
by calguy1000
try
{capture assign="testvar"}{content block="whatever"}{/capture}
{if isset($testvar)}{$testvar}{/if}

Re: hide all block when no content

Posted: Sun Jan 21, 2007 5:50 pm
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