GetSimple Support Forum

Full Version: Show <div> only when it contains some content
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hello,

I'm more or less new to GS (tried it some times before) and I have a question if it's possible to make it so that a <div> in a template only shows up in the FE when it has some content given.
In a CMS that I use atm it's done with php
Code:
ob_start
Thanks for helping!
Hans
try to do it with a simple if
PHP Code:
<?php
$content 
'your content or something what You want to show';
if (
$content != ''){
echo 
'<div>'$content '</div>';
}
?>
Thanks XXDEX

I'll give it a try.


(2014-09-01, 18:15:26)xxdex Wrote: [ -> ]try to do it with a simple if
PHP Code:
<?php
$content 
'your content or something what You want to show';
if (
$content != ''){
echo 
'<div>'$content '</div>';
}
?>
I suggest you use a different name for that variable, e.g. $mycontent instead of $content, if you're going to use it in your template. Otherwise there could be some conflict with GS as it uses a $content variable.
Thanks Carlos

As I'm new to GS I have to dig bit deeper in the script but I'll try ;-)
Hans

(2014-09-01, 23:16:26)Carlos Wrote: [ -> ]I suggest you use a different name for that variable, e.g. $mycontent instead of $content, if you're going to use it in your template. Otherwise there could be some conflict with GS as it uses a $content variable.