GetSimple Support Forum

Full Version: If page_content() != '' echo ... possible? (conditional by content)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm searching again for a php code to use in a template file.
I want to check if the content is empty (no content).
Example:
Code:
<?php if (page_content() != '') { ?>
        <section class="cssborder and more">
            <?php get_page_content(); ?>
        </section>    
<?php } ?>
Have tried "get_page_content()", "return_page_content()" and "page_content()" and "getPageContent()".
Thank you for helping again...

EDIT: I think I got it: "returnPageContent(return_page_slug())" is doing the job in v3.1. Maybe it would be helpful to add all the return outputs (if they are short/simple) for the main Template Tags in the Wiki?
Add the below function to admin/inc/theme_functions.php or theme/yourtheme/functions.php.
It does not matter which one you add it too.
Code:
function return_page_content() {
    global $content;
    exec_action('content-top');
    $content = strip_decode($content);
    $content = exec_filter('content',$content);
    return $content;
        /* un-comment below if you replace the get_page_content() function in your template files */
    //exec_action('content-bottom');
}

Then you can use it to return the content instead of echo it.

Or

You can do the below in your template files:
Code:
<?php
    global $content;
    if($content != '')
    {
        get_page_content();
    }
?>
Thank you mikeh! Until now I have no functions.php and prefer to continue with template.php only. But it is nice to have your code here in case I need to use functions.php.
ChriS Wrote:Thank you mikeh! Until now I have no functions.php and prefer to continue with template.php only. But it is nice to have your code here in case I need to use functions.php.

I revised my post. You do not have to use that function if you do not want to. You can stay within your template file.
Thanks for the new piece of code. I have edited my first post at the same time as your first post here. I mean I'm using
Code:
<?php if (returnPageContent(return_page_slug()) != '') { ?>
        <div class="style">
        <?php get_page_content(); ?>
        </div>
<?php } ?>

Does this code have some disadvantage in comparison to yours (I need to output the styling div)?