简体   繁体   English

INCLUDE函数有效,但不引用CSS

[英]INCLUDE function works but does not refer to CSS

I am working on restyling a phpbb board. 我正在重新设计phpbb板。 Even if there is a support forum on the phpbb platform, I would like to ask for your kind help. 即使在phpbb平台上有一个支持论坛,我也想寻求您的帮助。

I managed to include a footer.php file into overall_footer.html . 我设法将footer.php文件包含到了overall_footer.html The paths are: 路径是:

WEBSITE/forum/styles/stylename/template/overall_footer.html
WEBSITE/footer.php

the function: <!-- INCLUDEPHP /../../../../footer.php --> 函数: <!-- INCLUDEPHP /../../../../footer.php -->

The problem is that, while in other pages footer.php correctly refers to the stylesheet located in 问题是,尽管在其他页面中, footer.php正确地引用了位于

WEBSITE/stylesheet.css

once included in the board it does not refer to it at all... If I add the traditional <link href="...." rel="stylesheet" to footer.php , the stylesheet then applies to the whole board (that should have css defined by the chosen theme). 一旦包含在木板中,它根本就不会引用它。如果我将传统的<link href="...." rel="stylesheet"footer.php ,则该样式表将应用于整个木板(应该具有由所选主题定义的CSS)。 What is the obvious thing that I just can't see? 我看不到的显而易见的东西是什么? Any help is truly appreciated! 任何帮助,我们都感激不尽! Mya 妙雅

You are better off referencing your assets relative to a known point on your site. 最好参考相对于站点上已知点的资产。

There are several techniques for this... like: 有几种技术可以...

Use the document root as your starting point 使用文档根目录作为起点

include ($_SERVER["DOCUMENT_ROOT"] . "/includes/myfunctions.php");

or set up a constant 或设置一个常量

define("APP_ROOT", $_SERVER["DOCUMENT_ROOT"]);

or even in a .htaccess file 甚至在.htaccess文件中

SetEnv APP_ROOT "/path/to/myroot";

For URL based includes (js /css/ hrefs) 对于基于URL的包含(js / css / hrefs)

Always use absolute paths when referring to assets on your site (beginning with a /) except for images and fonts loaded from within a css file, those can be loaded relative to the css file. 引用站点上的资产时,始终使用绝对路径(以/开头),但从css文件中加载的图像和字体除外,这些可以相对于css文件加载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM