更改产品页面上的正文背景

时间:2013-01-22 16:42:38

标签: php html css

我正在为学校做一个项目。截止日期是明天。 当网址为:时,我想更改正文标记并在产品页面上添加背景图片: index.php?category = nieuwBinnen& product = Belair + X ch

我怎样才能做到这一点。我尝试了if isset方法但结果没有成功。 您可以在http://alisgfx.com/lomo/上看到该网站 我感谢任何帮助。

阿里

的index.php     

# geef de HTML code voor het openen van de pagina weer
htmlOpenen('Titel van de website');

# toon de header
toonHeader();

include 'menu.php';

?>

<?php 

if (isset($_GET['category']) && isset($_GET['product']) && isset($$_GET['category'])){  //display product if provided
    $category = $$_GET['category'];
    $product = $_GET['product'];
    $error_msg = 1;  //sets a basic error catcher in case product does not exist
    foreach ($category as $item) {
       if ($item['naam'] == $product) {
        echo '
        <section>
        <article class="product">
            <h2 class="item_name">'.$item['naam'].'</h2>

            <div id="image">'.$item['foto'].'</div>
            <p>'.$item['video'].'</p>
            <p>
                '.$item['fotos'].'
            </p>
        </article>
        ';

        echo '
            <article class="product simpleCart_shelfItem">
                <div id="slider3">
                    <ul class="pager">
                        <li><a href="" class="pagenum active" rel="0">Info</a></li>
                        <li><a href="" class="pagenum" rel="1">Reviews</a></li>
                        <li><a href="" class="pagenum" rel="2">Extra\'s</a></li>
                    </ul>                           
                    <div class="viewport">
                        <ul class="overview">
                            <li class="page"><p> '.$item['info'].' <hr />'.$item['prijs'].'Beschikbaarheid: '.$item['beschik'].' <br /><br />Aantal: <input type="text" value="1" class="item_Quantity"></p></li>
                            <li class="page"><p>'.$item['reviews'].'</p></li>
                            <li class="page"><p>'.$item['extras'].'</p></li>
                        </ul>
                    </div>
                </div>
                    <h2 class="item_name hide"> '.$item['naam'].' </h2>
                    <p class="hide">'.$item['thumb'].'</p>
                    <a class="item_add" href="javascript:;"> Plaats product <br />in je winkelmandje </a>                
            </article>
        ';

        echo '
            <article class="product box-shadow">
                <p>Met deze camera<br /> kun je zulke foto\'s<br /> maken</p>
                <div id="slider4">
                    <a class="buttons prev" href="#">left</a>
                        <div class="viewport">
                            <ul class="overview">
                                '.$item['upload'].'
                            </ul>
                        </div>
                    <a class="buttons next" href="#">right</a>
                </div>
                <!-- <form action="" method="post">
                    <input type="file" name="bestand"><br>
                    <input type="submit" name="submit" value="Upload foto">
                </form> -->

                <a class="upload" href="upload">Upload je<br /> eigen foto\'s</a>   
            </article>

            <article class="product">
                <p>filmrolletje</p>
            </article>
            </section>
        ';

        // echo $item['prijs']."<br/>";
        // echo $item['product']."<br/>";

        // echo $item['info']."<br/>";

        $error_msg = 0;
       }       
    }
 if ($error_msg){ //basic error message in case product does not exist
     echo 'The selected product no longer exists';
 } 
}          
else{  //displays all product if specific product not given
?>


<!-- producten carousel -->
<section class="carousel">
    <div class="banner"><img src="img/nieuw.jpg"></div>
    <div id="slider1">
        <a class="buttons prev" href="#">left</a>
        <div class="viewport">
            <ul class="overview">
                <?php 
                foreach($nieuwBinnen as $new) {
                    echo '
                        <li>
                            <a href="index.php?category=nieuwBinnen&product='.urlencode($new['naam']).'">
                            <p>'.$new['product'].'</p>
                            <h2>'.$new['naam'].'</h2>
                            </a>
                        </li>
                    ';
                }
                ?>
            </ul>
        </div>
        <a class="buttons next" href="#">right</a>
    </div>
</section>

<!-- producten carousel -->
<section class="carousel">
    <div class="banner"><img src="img/best.jpg"></div>
    <div id="slider1">
        <a class="buttons prev" href="#">left</a>
        <div class="viewport">
            <ul class="overview">
                <?php 
                foreach($bestSellers as $best) {
                    echo '
                        <li>
                            <a href="index.php?category=bestSellers&product='.urlencode($best['naam']).'">
                            <p>'.$best['product'].'</p>
                            <h2>'.$best['naam'].'</h2>
                            </a>
                        </li>
                    ';
                }
                ?>
            </ul>
        </div>
        <a class="buttons next" href="#">right</a>
    </div>
</section>
<?php
}

include 'footer.php';

?>

inc.template.inc.php

<?php

# Public: Echo de HTML code voor het openen van de pagina
#
# $titel    - Een tekst die tussen de <title> en </title> tags wordt geplaatst
#
# Examples:
#
#   htmlOpenen('pagina titel');
#   # => geeft onderstaande html weer
function htmlOpenen($titel){
    # Geef de HTML openen code weer
    echo '<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title>Lomography</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width">

        <!-- Place favicon.ico and apple-touch-icon.png in the root directory -->

        <link rel="stylesheet" href="css/normalize.css">
        <link rel="stylesheet" href="css/main.css">
        <link rel="stylesheet" href="css/jquery-ui.css">
        <link rel="stylesheet" href="./fancybox/source/jquery.fancybox.css">
        <script src="js/vendor/modernizr-2.6.2.min.js"></script>
    </head>
    <body>
        <!--[if lt IE 7]>
            <p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
        <![endif]-->


        <section id="container" class="clearfix">
    ';
}


function htmlOpenenCart($titel){
    # Geef de HTML openen code weer
    echo '<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title>Lomography</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width">

        <!-- Place favicon.ico and apple-touch-icon.png in the root directory -->

        <link rel="stylesheet" href="css/normalize.css">
        <link rel="stylesheet" href="css/main.css">
        <link rel="stylesheet" href="css/jquery-ui-cart.css">
        <link rel="stylesheet" href="./fancybox/source/jquery.fancybox.css">
        <script src="js/vendor/modernizr-2.6.2.min.js"></script>
    </head>
    <body>
        <!--[if lt IE 7]>
            <p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
        <![endif]-->


        <section id="container" class="clearfix">
    ';
}



function toonHeader() {
    echo '
        <header>
            <a id="logo" href="index.php"><img src="img/logo.png" alt="Lomography Shop"></a>

            <nav id="mainNavigation">
                <ul>
                    <li><a href="inloggen.php">inloggen</a></li>
                    <li><a href="registreren.php">registreren</a></li>
                    <li><a href="over-ons.php">over ons</a></li>
                </ul>
            </nav>

            <div class="cartInfo"><span class="simpleCart_quantity"></span> items</div>
            <div id="cartPopover">
                <div id="triangle">&#x25B2;</div>
                <div class="simpleCart_items"></div>
                <div id="cartData" class="clearfix">
                    <div class="left"><strong>Items: </strong><span class="simpleCart_quantity"></span></div>
                    <div class="right"><strong>Total: </strong><span class="simpleCart_total"></span></div>
                </div>
                <div id="popoverButtons" class="clearfix">
                    <a href="cart.php?stap=1" class="hudbtn left">View</a>
                    <!-- <a href="javascript:;" class="simpleCart_checkout hudbtn primary right">Checkout</a> -->
                </div>
            </div><!--End #cartPopover-->

            <div id="zoeken">
                <form method="get" action="/search" id="search">
                    <input name="q" type="text" size="40" placeholder="Search..." />
                </form>
            </div>
        </header>
    ';
}


?>

3 个答案:

答案 0 :(得分:0)

您可以使用JavaScript / JQuery动态设置它。

答案 1 :(得分:0)

可以尝试类似:

$targetpage =  $_SERVER['SERVER_NAME'].'/index.php?category=nieuwBinnen&product=Belair+X'
   if (!$targetpage) {
          echo background 1;
    }else{
          echo background 2;
    }

答案 2 :(得分:0)

$ class='no-bgimage'; if (isset($_GET['product']) {
    $class='bgimage';
}

然后在你的身体

<body class="<?php echo $class ?>">

然后在你css

.bgimage {
background-image: url('page/to/your/image');
}