Header link advice

Discussion in 'HTML' started by Confused but working on it, Sep 20, 2007.

  1. Good Morning,

    I have a reasonably simple site hat I've started to organize a bit
    better. Most everything was in the main directory, same as the index
    file. I use a header and footer PHP include on every page and just
    realized that the links in my header file give a 404 error.
    From the index page I link to /dogs/poodles/poodles.php
    In poodles.php i include:
    <?php include("../../header.php"); ?>
    The ../../ get the header file from the main directory of the site.

    So now the hader thinks the other site files are in the poodles
    directory when in reality most are still in the same as index.

    My solution is to have multiple header files like:
    <?php include("header.php"); ?>
    <?php include("../header1.php"); ?>
    <?php include("../../header2.php"); ?>
    <?php include("../../../header3.php"); ?>
    and then inside of each header file rework the links. This would work
    and pick how deep the calling file is. But this would be dumb as I
    would have to change 4 header files.

    I have an older HTML4 book but it doesn't really touch on this. Am I
    missing something amazingly simple?

    TIA,
    Ron
     
    Confused but working on it, Sep 20, 2007
    #1
    1. Advertising

  2. Confused but working on it

    Chaddy2222 Guest

    On Sep 21, 2:09 am, Confused but working on it
    <> wrote:
    > Good Morning,
    >
    > I have a reasonably simple site hat I've started to organize a bit
    > better. Most everything was in the main directory, same as the index
    > file. I use a header and footer PHP include on every page and just
    > realized that the links in my header file give a 404 error.
    > From the index page I link to /dogs/poodles/poodles.php
    > In poodles.php i include:
    > <?php include("../../header.php"); ?>
    > The ../../ get the header file from the main directory of the site.
    >
    > So now the hader thinks the other site files are in the poodles
    > directory when in reality most are still in the same as index.
    >
    > My solution is to have multiple header files like:
    > <?php include("header.php"); ?>
    > <?php include("../header1.php"); ?>
    > <?php include("../../header2.php"); ?>
    > <?php include("../../../header3.php"); ?>
    > and then inside of each header file rework the links. This would work
    > and pick how deep the calling file is. But this would be dumb as I
    > would have to change 4 header files.
    >

    <snip>
    Check out this link:
    http://www.webmasterworld.com/forum88/10358.htm
    I hope that helps.
    --
    Regards Chad. http://freewebdesign.awardspace.biz
     
    Chaddy2222, Sep 20, 2007
    #2
    1. Advertising

  3. Confused but working on it

    Jim Moe Guest

    Confused but working on it wrote:
    >
    > I have a reasonably simple site hat I've started to organize a bit
    > better. Most everything was in the main directory, same as the index
    > file. I use a header and footer PHP include on every page and just
    > realized that the links in my header file give a 404 error.
    > From the index page I link to /dogs/poodles/poodles.php


    > In poodles.php i include:
    > <?php include("../../header.php"); ?>
    > The ../../ get the header file from the main directory of the site.
    >
    > So now the header thinks the other site files are in the poodles
    > directory when in reality most are still in the same as index.
    >

    Another option is to define a base directory variable in a common file
    that all pages include:

    require('/path/to/base-paths.inc');
    $phpbase = '/path/to/root/of/php/code/';

    Then all includes are accessed by:
    include($phpbase . 'file.php');

    The advantage here is the option to have other common or global
    variables defined in <base-paths.inc> that may not be related directly to PHP.

    --
    jmm (hyphen) list (at) sohnen-moe (dot) com
    (Remove .AXSPAMGN for email)
     
    Jim Moe, Sep 20, 2007
    #3
  4. On 2007-09-20 11:14:02 -0700, Jim Moe <> said:

    > Confused but working on it wrote:
    >>
    >> I have a reasonably simple site hat I've started to organize a bit
    >> better. Most everything was in the main directory, same as the index
    >> file. I use a header and footer PHP include on every page and just
    >> realized that the links in my header file give a 404 error.
    >> From the index page I link to /dogs/poodles/poodles.php

    >
    >> In poodles.php i include:
    >> <?php include("../../header.php"); ?>
    >> The ../../ get the header file from the main directory of the site.
    >>
    >> So now the header thinks the other site files are in the poodles
    >> directory when in reality most are still in the same as index.
    >>

    > Another option is to define a base directory variable in a common file
    > that all pages include:
    >
    > require('/path/to/base-paths.inc');
    > $phpbase = '/path/to/root/of/php/code/';
    >
    > Then all includes are accessed by:
    > include($phpbase . 'file.php');
    >
    > The advantage here is the option to have other common or global
    > variables defined in <base-paths.inc> that may not be related directly to PHP.


    Jim,

    Thanks for your time. This is a bit of thinking out loud as I'm not
    proficient with php.

    I use:
    <?php include("header.php"); ?> and also one for the footer, in all of
    my files.

    So in every file after <body> use the require like:
    <?php require(('/path/to/base-paths.inc');
    $phpbase = '/path/to/root/of/php/code/'; ?>

    Then call my header file,
    Content,
    footer call

    I'm not understanding the include($phpbase and the concatenation to file.php

    Just came back from a few days in Vegas so maybe a bit slow. :)

    thx..ron
     
    Confused but working on it, Sep 25, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Spencer

    Re: Link Link Link DANGER WILL ROBINSON!!!

    Kevin Spencer, May 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    893
    Kevin Spencer
    May 17, 2005
  2. Asun Friere
    Replies:
    1
    Views:
    513
    Paul Boddie
    Aug 27, 2003
  3. Peter Hansen
    Replies:
    23
    Views:
    896
    Anton Vredegoor
    Sep 5, 2003
  4. Gerrit Holl
    Replies:
    16
    Views:
    631
    Tom Plunket
    Aug 29, 2003
  5. mlt
    Replies:
    2
    Views:
    883
    Jean-Marc Bourguet
    Jan 31, 2009
Loading...

Share This Page