WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Droplets & Snippets => Topic started by: ledob44 on August 05, 2010, 02:43:03 PM

Title: Know when a page_content is not empty
Post by: ledob44 on August 05, 2010, 02:43:03 PM
Hello, here's a little code to check if a wysiwyg page_content contains datas. I put it in the frontend.functions. php

Code: [Select]
function isPageContent($num){
ob_start();
page_content($num);
$content=ob_get_contents(); 
ob_end_clean();
if($content != ''){
return $content;
}else{
return false;
}
}

To use it :

Code: [Select]
$content = isPageContent(numberOfYouBlock);
if($content){
       echo '
          <div id="test">
               <h2>Promo</h2>
               '.$content.'
          </div>
        ';
}

It's very usefull when you have some html specific construction linked to a wysiwyg. Like that, webmaster don't have to put some extra code in the wysiwyg.

P.S : sorry for my english
Title: Re: Know when a page_content is not empty
Post by: LuuQ on December 24, 2010, 05:21:47 PM
Oh dear!

You saved me an hour. Thank you very much for posting this. I was searching exactly for this piece of code. I just typed "page_content" in the search field of the forum and got your post. It's really exactly what I need.

And by the way, I think your English is alright!


Thanks again and best regards,

LuuQ
Title: Re: Know when a page_content is not empty
Post by: Argos on December 27, 2010, 12:59:08 AM
See also https://forum.WebsiteBaker.org/index.php/topic,18231.msg121394.html#msg121394