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).
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.
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?
This topic is now closed. New replies are no longer allowed.