user3360270
user3360270

Reputation:

echo a div class

I have a problem, when I try to echo a div class. When I put the following code in my template, it detects only the closing tag and not the opening. So, my webpage is ruined:

<div id="container">
    <div id="pagina_text">

        {{ CONTENT }}
        <br />
        <div class="rw-ui-container"></div>
        <br /><br />
        <?php
            var_dump($_GET['categorie']);
            if(isset($_GET['categorie']) && $_GET['categorie'] === "navigatie_bar")
            {
                echo "<div class=\"fb-comments\" data-href=\"http://alledaagsetips.nl\"  data-numposts=\"10\" data-colorscheme=\"light\"></div>";
            }
        ?>
    </div> <!-- end pagina_text -->
</div><!-- end container -->

Does someone know what am I doing wrong?

Upvotes: 1

Views: 828

Answers (4)

Nurdin
Nurdin

Reputation: 23883

Replace single quote with double quote.

Change

<?php
if(strcmp($_GET['categorie'], "navigatie_bar") != 0)
{
echo '<div class="fb-comments" data-href="http://alledaagsetips.nl"  data-numposts="10" data-colorscheme="light"></div>';
}
?>

to this

<?php
if(strcmp($_GET['categorie'], 'navigatie_bar') != 0)
{
echo "<div class='fb-comments' data-href='http://alledaagsetips.nl'  data-numposts='10' data-colorscheme='light'></div>";
}
?>

Upvotes: 1

Krucamper
Krucamper

Reputation: 371

<div id="container">
    <div id="pagina_text">
        {{ CONTENT }}
         <br>
         <div class="rw-ui-container"></div>
         <br><br>
        <?php if ( ! empty($_REQUEST['categorie']) and $_REQUEST['categorie'] == 'navigatie_bar'): ?>
        <div class="fb-comments" data-href="http://alledaagsetips.nl"  data-numposts="10" data-colorscheme="light"></div>
        <?php endif; ?>
     </div> <!-- end pagina_text -->
</div><!-- end container -->

Upvotes: 0

Sadık
Sadık

Reputation: 4419

replace single quotes with double and vice versa

echo "<div class='fb-comments' data-href='http://alledaagsetips.nl'  data-numposts='10' data-colorscheme='light'></div>";

or use the same for all but with backslash, just to not get confused

echo "<div class=\"fb-comments\" data-href=\"http://alledaagsetips.nl\"  data-numposts=\"10\" data-colorscheme=\"light\"></div>";

Upvotes: 0

MaoTseTongue
MaoTseTongue

Reputation: 1505

Are you sure the "IF" condition is working?

Perhaps with a simple string comparison like so :

<?php
if(isset($_GET['categorie']) && $_GET['categorie'] === "navigatie_bar") {
    echo '<div class="fb-comments" data-href="http://alledaagsetips.nl" data-numposts="10" data-colorscheme="light"></div>';
}
?>

Upvotes: 0

Related Questions