SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jan 2012
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    universal include header.php if possible, please

    dear all,

    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[‘DOCUMENT_ROOT’].”/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).

    Respectfully yours`
    sehrguey ogoltsoff

  2. #2
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    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.
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  3. #3
    SitePoint Member
    Join Date
    Jan 2012
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    dear AnthonySterling,

    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?

    beggardly yours`
    sehrguey


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •