如何从URL中获取值,并且不显示具有特定值的模板中的div

时间:2014-02-27 11:48:15

标签: php html

我想省略当有人点击侧边栏或导航栏时显示的template.html的div。当一个类别是navigation_bar时,我希望它留下像Facebook评论框这样的东西。因为仅在侧栏页面上需要它。

网址示例index.php?catagory=navigation_bar&subject=contact

我在考虑这样的事情:

<php?

if (isset($_GET['catagory']))
{
   $catagory = $_GET['categorie'];

    if $catagory = navigatie_bar
    {
      //here something that says: then don't display <div class="fb-comments'></div>
    }

}
?>

有人可以帮助我吗?

2 个答案:

答案 0 :(得分:0)

这就是你要找的 -

 <?php

    if (isset($_GET['catagory']))
    {
       $catagory = $_GET['categorie'];

        if $catagory = navigatie_bar
        {
          //here something that says: then don't display <div class="fb-comments'></div>
        }

    }
    ?>
    <input type="hidden" value="<?php echo $category?>" id="tohide"/>
    <div id="comment">comments....</div>
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script>
    $(document).ready({
    var id=$("tohide").val();
    $("#"+id).hide();
    });
    </script>

答案 1 :(得分:-1)

你试过的似乎是正确的比特修正,

//This condition says show fb comment on all pages but navigation_bar
if(isset($_GET['catagory']) && $_GET['catagory'] != "navigatie_bar")
{
    echo " <div class='fb-comments'></div>";
    //Your code goes here
}