kyankli — 2012-02-09T09:11:32-05:00 — #1
I wanna make universal header/footer include files.
Universal here means to be applicable in files on any directory level without need to add “../” at any deeper level when calling “header.php” from “includes” directory.
Ok, fine. I can use
<?php include $SERVER[‘DOCUMENTROOT’].”/includes/header.php”;?>
to have it anywhere but the header.php contains a relative reference to a .css file and the .css file contains its relative references (for instance “background: url(../images/o.gif);” and all that lands me in a quagmire of “../../” at every new level.
Of course, I could replicate the .css and ../images at every level yet it seems a bit awkward and contrary to the very principle and spirit of the great php (control all at one place).
anthonysterling — 2012-02-09T09:28:46-05:00 — #2
You could set a "base href" in your HTML template. Or, you could define a constant which indicates the web and app root, then just use this to anchor the calls to your assets.
kyankli — 2012-02-09T12:04:20-05:00 — #3
thank you for noticing my problem.
I fear my terminology ken is not so wide to fully appreciate your kind advise.
Could you translate it into a couple of one-liners?