Author Topic: Know when a page_content is not empty  (Read 4629 times)

Offline ledob44

  • Posts: 2
Know when a page_content is not empty
« 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
« Last Edit: August 05, 2010, 02:48:57 PM by ledob44 »

Offline LuuQ

  • Posts: 96
  • Gender: Male
Re: Know when a page_content is not empty
« Reply #1 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

Offline Argos

  • Posts: 2542
  • Gender: Male
    • Argos Media
Jurgen Nijhuis
Argos Media
Heiloo, The Netherlands
----------------------------------------------------------------
Please don't request personal support, use the forums!