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 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大