GetSimple Support Forum
QUESTION Show <div> only when it contains some content - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: General Questions and Problems (http://get-simple.info/forums/forumdisplay.php?fid=16)
+--- Thread: QUESTION Show <div> only when it contains some content (/showthread.php?tid=6697)



Show <div> only when it contains some content - meetje - 2014-09-01

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


RE: Show <div> only when it contains some content - xxdex - 2014-09-01

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>';
}
?>



RE: Show <div> only when it contains some content - meetje - 2014-09-01

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>';
}
?>



RE: Show <div> only when it contains some content - Carlos - 2014-09-01

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.


RE: Show <div> only when it contains some content - meetje - 2014-09-02

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.