Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QUESTION Show <div> only when it contains some content
#1
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
Reply
#2
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>';
}
?>
user plugin: scroll to top
Reply
#3
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>';
}
?>
Reply
#4
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.
Reply
#5
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.
Reply




Users browsing this thread: 1 Guest(s)