duanchongchu5177 2014-05-07 09:38 采纳率: 0%
浏览 152
已采纳

在首页上隐藏页眉和页脚,但在其他页面上显示EDITED

So, I have a simple website with dynamically generated menu in the header and footer sections (different style for both, for footer more like a page map). I include header and footer blocks with php. So, I have a problem: I need the header and footer blocks to be seen only on other pages, not the first one- Home- page, because of different styling. I tried to do : if (content == "home") { echo .header, .footer { display: hidden;"}; but it doesn't work when I first load the page! Maybe you guys have some ideas? Thank you in advance!

Here is my code:

<?php
$languages = array("eng","lat", "ru");
$sections = array("home", "about", "cafe", "catering", "gallery", "contact");
$sectionTitles = array("eng" =>array("ABOUT US", "CAFE MENU"), "lat"=>array("PAR MUMS", "ĒDIENKARTE"), "ru" =>array("ru1","ru2",));                     
$lang = "eng";
$section = "home";

$content = explode("/", $_SERVER['REQUEST_URI']);

if (!empty($content[2]) && (in_array($content[2], $languages))) { $lang = $content[2];}
if (!empty($content[3]) && (in_array($content[3], $sections))) { $section = $content[3];}
$sectionTitles = $sectionTitles[$lang];

require_once ("header.php");
require_once ("$lang/$section.php");
require_once ("footer.php");
?>

Header file:

<div class="header">Some header info+menu. Not visible on first page</div>

Content file:

<div class="content">Content different for every page.</div>

Footer file:

<div class="footer">Footer info+page map. Not visible on first page.</div>
  • 写回答

3条回答 默认 最新

  • douyi6755 2014-05-07 09:59
    关注

    Change the require part of your code to;

    if ("$lang/$section.php" === "$lang/home.php") {
        require_once ("$lang/$section.php");
    }else{
        require_once ("header.php");
        require_once ("$lang/$section.php");
        require_once ("footer.php");
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 ansys fluent计算闪退
  • ¥15 有关wireshark抓包的问题
  • ¥15 需要写计算过程,不要写代码,求解答,数据都在图上
  • ¥15 向数据表用newid方式插入GUID问题
  • ¥15 multisim电路设计
  • ¥20 用keil,写代码解决两个问题,用库函数
  • ¥50 ID中开关量采样信号通道、以及程序流程的设计
  • ¥15 U-Mamba/nnunetv2固定随机数种子
  • ¥15 vba使用jmail发送邮件正文里面怎么加图片
  • ¥15 vb6.0如何向数据库中添加自动生成的字段数据。