2012-10-09 63 views
1

我想在我的網站中使用PHP include,所以使新頁面變得非常容易,但我遇到了一個問題。我也想在這個header.php中包含我的導航,但是我的問題是,我在活動頁面上有一個活動類,所以我想知道如何使用PHP來做到這一點。這是我現在在我的header.php中所擁有的,但我無法弄清楚。Bootstrap PHP頭文件

<?php 
function pageName($name=""){ 

print " 
<html lang="en"> 
<head> 
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> 
    <meta http-equiv="Content-Language" content="en-gb" /> 
    <meta name="keywords" content="Minecraft Hosting, Minecraft, Hosting, VoxelHost, VoxelHost, Cheap, Reliable, Great Support, Great, Support, Europe, Best Minecraft Host, Best, Minecraft, Host" /> 
    <meta name="description" content="Voxel Host delivers Cheap and Reliable Hosting Solutions for your daily needs." /> 
    <link rel="shortcut icon" type="image/png" href="https://www.voxelhost.com/img/icon.png" /> 
    <title>Voxel Host - Cheap And Reliable Hosting Solutions</title> 
    <link rel="stylesheet" type="text/css" href="https://www.voxelhost.com/css/bootstrap.css" media="all" /> 
    <link rel="stylesheet" type="text/css" href="https://www.voxelhost.com/css/voxelhost.css" media="all" /> 
    <link rel="stylesheet" type="text/css" href="https://www.voxelhost.com/css/nivo-slider.css" media="all" /> 
    <link rel="stylesheet" type="text/css" href="https://www.voxelhost.com/css/default.css" media="all" /> 
    <link rel="stylesheet" type="text/css" href="https://www.voxelhost.com/css/font-awesome.css" /> 
    <script type="text/javascript" src="https://www.voxelhost.com/js/jquery.min.js"></script> 
    <script type="text/javascript" src="https://www.voxelhost.com/js/bootstrap.min.js"></script> 
    <script type="text/javascript" src="https://www.voxelhost.com/js/jquery.slider.nivo.js"></script> 
    <!--Start of Zopim Live Chat Script--> 
    <script type="text/javascript"> 
     window.$zopim||(function(d,s){var z=$zopim=function(c){z._.push(c)},$=z.s= 
     d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set. 
     _.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute('charset','utf-8'); 
     $.src='//cdn.zopim.com/?bIkq1WcfGahuJo4awX9QoDtEdvXXAClp';z.t=+new Date;$. 
     type='text/javascript';e.parentNode.insertBefore($,e)})(document,'script'); 
    </script> 
    <!--End of Zopim Live Chat Script--> 
    <script type="text/javascript"> 
     var _gaq = _gaq || []; 
     _gaq.push(['_setAccount', 'UA-35044907-1']); 
     _gaq.push(['_setDomainName', 'voxelhost.com']); 
     _gaq.push(['_trackPageview']); 

     (function() { 
      var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; 
      ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; 
      var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); 
     })(); 

    </script> 
</head> 
<body> 
    <div class="alertbar inactive"></div> 
    <div class="infobar">We are starting the 20th of October! See you soon!</div> 
    <div class="succesbar inactive"></div> 
    <div id="topbar"> 
     <ul> 
      <li><a href="https://www.voxelhost.com/billing/supporttickets.php">Support Ticket</a></li> 
      <li><a href="mailto:[email protected]">Email</a></li> 
      <li><a href="skype:martijnriemers?chat">Skype</a></li> 
     </ul> 
    </div> 
    <div id="logo"> 
     <div class="align"> 
      <div class="left" style="width: 500px;"> 
       <a href="#"><img src="https://www.voxelhost.com/img/logo.png" /></a> 
      </div> 
      <div class="clear"></div> 
     </div> 
    </div> 
    <div id="wrapper"> 
     <div class="container"> 
      <div class="navbar" id="navbarhomepage"> 
       <div class="navbar-inner"> 
        <div class="container"> 
         <ul class="nav"> 
          <li class="active"><a href="https://www.voxelhost.com/"><i class="icon-home"></i> &nbsp;Home</a></li> 
          <li class="dropdown"> 
           <a href="#" class="dropdown-toggle"><i class="icon-star"></i> &nbsp;Services</a> 
           <ul class="dropdown-menu"> 
            <li><a href="https://www.voxelhost.com/minecraft/standard">Standard Minecraft Servers</a></li> 
            <li><a href="https://www.voxelhost.com/minecraft/premium">Premium Minecraft Servers</a></li> 
            <li><a href="https://www.voxelhost.com/minecraft_reseller">Minecraft Reseller</a></li> 
            <li><a href="https://www.voxelhost.com/comingsoon">VPS Hosting</a></li> 
            <li><a href="https://www.voxelhost.com/comingsoon">Dedicated Servers</a></li> 
            <li><a href="https://www.voxelhost.com/comingsoon">Web Hosting</a></li> 
           </ul> 
          </li> 
          <li><a href="https://www.voxelhost.com/status"><i class="icon-ok-sign"></i> &nbsp;Server Status</a></li> 
          <li><a href="https://www.voxelhost.com/billing/cart"><i class="icon-shopping-cart"></i> &nbsp;Order Now</a></li> 
          <li><a href="https://www.voxelhost.com/billing/"><i class="icon-user"></i> &nbsp;Client Area</a></li> 
          <li class="dropdown"> 
           <a href="#" class="dropdown-toggle"><i class="icon-dashboard"></i> &nbsp;Control Panels</a> 
           <ul class="dropdown-menu"> 
            <li><a href="https://mcpanel.voxelhost.com/">Minecraft Servers</a></li> 
            <li><a href="https://mintpanel.voxelhost.com/">Game Servers</a></li> 
            <li><a href="https://cpanel.voxelhost.com/">Webhosting</a></li> 
           </ul> 
          </li> 
         </ul> 
        </div> 
       </div> 
      </div> 
     </div> 
     <div id="content">" ; 

} 
?> 

而這就是我在我的index.php等

<?php 
include("header.php"); 
pageName("Home"); 
?> 

讀這篇文章,也許幫助我非常感謝!

+0

你談論導航CSS'類=「active'動態選擇基於該所選擇的頁面 –

+0

是的,沒錯這就是我的問題。 –

回答

3

您的報價導致問題。

轉儲大的字符串,請嘗試使用HEREDOC:

print <<<EOT 
<html lang="en"> 
    .......... 
EOT; 
+0

非常好我沒有考慮它我刪除了我的答案 –

+0

好吧,但是如何使用php來改變活動類呢?我發現這個,https://forums.totalchoicehosting.com/index.php? showtopic = 23306,這是我應該使用的嗎? –

+0

但是,如果我更新標題,我必須更新所有30頁,這將需要很長時間。如果我可以使用一個header.php並有一個代碼管理我的「主動」課導航它會節省很多時間。 –