dpwqicw157673 2015-08-28 15:50
浏览 77
已采纳

使用CSS / Javascripting包含的PHP站点结构技术

Technique #1:

  • Single index.php file which includes header.php, navigation.php, footer.php and content files depending on URL variable.

Problems #1:

  • You can't add individual .CSS files specific to your content pages because they have to be added in the main index.php file and may conflict with other content pages.
  • If you have javascript's needed for specific content pages you MUST load all potentially used JS files in the index.php file. This means you unnecessarily load JS files for content pages where they aren't needed.

Technique #2:

  • template.php file for each major page of website which includes header.php, navigation.php, footer.php. Content is not included via a file but rather the template file is used as the content file.

Problems #2:

  • Any changes made to the the template has to be duplicated to every other major page manually.

I started using technique #1 until I ran into major javascript issues. I am now considering moving to technique #2 and just dealing with template changes as necessary.

What technique do you use and how do you solve the CSS/JS include issue?

  • 写回答

1条回答 默认 最新

  • dongpin1059 2015-08-28 16:05
    关注

    I tend to have one CSS for the whole web site or at most 2 CSS file when a unique CSS file will be very long. In such case, I define in the first CSS file the general ayout of the web site and the common structure shared by the web site pages, and in the second CSS file I will define the layout specific to a page or to an object.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决