0

I have a template for all my web pages but i want a div class not to be seen on certain pages. I use the URL to get the content out of a database with php so an example of my URL = index.php?categorie=navigatie_bar&onderwerp=startpagina

I need a code to say get catagory from the url and if catagory is not navigation_bar

 echo '<div class"fb-comments"></div>'; 

can someone help ?

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

                    {{ CONTENT }}
                    </br>
                    <div class="rw-ui-container"></div>
                    </br></br>
                    <?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>';
                         }
                        ?>
        </div> <!-- end pagina_text -->
        </div><!-- end container -->
  • I updated my answer. You make a lot of mistakes, then it is hard to find all the problems.. `
    ` not `` and also you have some closing bracket in the `echo`, why?
    – Asped Mar 12 '14 at 12:52
  • well i was just trying some things and if i put the > in there it seems to take the div class the right way –  Mar 12 '14 at 13:28

3 Answers3

0

I think this is just basic PHP, a simple condition. But you seem to have also errors in our template. I would suggest running a w3c validator check, so you can see what you have wrong (wrongly nested tags, syntax mistakes etc..) W3C Validator Online

UPDATE:

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

                    {{ CONTENT }}
                    <br />
                    <div class="rw-ui-container"></div>
                    <br /><br/>
                    <?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>';
                         }
                        ?>
        </div> <!-- end pagina_text -->
        </div><!-- end container -->
Asped
  • 3,083
  • 4
  • 31
  • 52
  • Yeah i tought so too but there is one problem. If i put this code in my template.html he doesn't detect the div opening as a div only the closing so it closes an other div and my webpage is ruined. –  Mar 12 '14 at 11:39
  • 1
    There is a '=' missing after class – Matthias S Mar 12 '14 at 11:41
  • Sorry @MatthiasS, you are right, I just copied his code ;) – Asped Mar 12 '14 at 11:45
  • It still doesn't work. he only detects the closing div not the start div.... what can i do ? –  Mar 12 '14 at 12:31
  • Maybe you could paste more code,otherwise it's hard to find the problem. The code above definitely has to work – Asped Mar 12 '14 at 12:33
  • Maybe you have problems in your template, like wrong nested tags – Asped Mar 12 '14 at 12:34
0

try this

<?php
if($_REQUEST['category'] != 'navigation_bar'){
 echo '<div class="fb-comments"></div>'; 
}else{ //do this }
?>
Haseeb
  • 2,214
  • 1
  • 22
  • 43
0

You can access the URL variables via $_GET['name_of_parameter'].

if(strcmp($_GET['category'], "navigation_bar") != 0)
{
  echo '<div class="fb-comments"></div>'; 
}

In this case, only if index.php?category=navigation_bar the div will be echoed.

Take attention to your spelling, in your example you wrote catagory instead of category

EDIT: You can do $_GET['category'] == 'navigation_bar', but for string comparisons it is sometimes safer to use the strcmp (string compare) function. See String comparison using == vs. strcmp

Community
  • 1
  • 1
Matthias S
  • 3,358
  • 3
  • 21
  • 31
  • still got the problem with the div. it only detects the closing tag and not the opening tag..... –  Mar 12 '14 at 12:33