include header?

Discussion in 'PHP' started by devo10, Jan 9, 2011.

  1. #1
    Hi

    I’m making a website and one of the things I want to do is use ‘include/header’ on my content pages.

    The site is using php and uses a login system. The header is made with css, and when I try to include it in a page in a different directory the header seems to break from its link to its css.

    I have two questions:

    1 How do I resolve this problem?

    2 Is it still goog practice it include the header? If not, what else could I do?

    Many thanks in advance
     
    devo10, Jan 9, 2011 IP
  2. ssmm987

    ssmm987 Member

    Messages:
    180
    Likes Received:
    4
    Best Answers:
    3
    Trophy Points:
    43
    #2
    Use the direct links to the css files.

    Or rewrite these links using mod rewrite.
     
    ssmm987, Jan 9, 2011 IP
  3. ankit_frenz

    ankit_frenz Active Member

    Messages:
    1,111
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    63
    #3
    make sure the relative paths are correct and its obviously a good practice to have a separate header file.This way you can change them easily whenever needed.
    Thanks
     
    ankit_frenz, Jan 9, 2011 IP
  4. devo10

    devo10 Active Member

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #4
    Hi ssmm987 and ankit

    Thanks for your input. I have my header in the root directory. I want to include in the sub-directory of another directory. When I do this, the header link to its css file is broken because it is being called from a different location.

    ssmm987, I have read about ‘mod rewrite’. I’m not sure this will help this problem. I think the link is breaking because its being called from a ‘new’ location. How can I resolve this as I want to only use one header and its css file?

    Thanks again
     
    devo10, Jan 9, 2011 IP
  5. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #5
    Try using
    href="./directory/style.css"
    Code (markup):
    or don't forget you can always use the full url
    href="http://domain.com/directory/directory/style.css"
    Code (markup):
     
    MyVodaFone, Jan 9, 2011 IP
  6. Raymond_M

    Raymond_M Peon

    Messages:
    79
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    If you have the header added to your index.php page and that links to the css file, but then add the header to say products.php it will not keep the css unless you have the css file linked to in the products.php page also.

    Also use the full URL to make sure that isn't an issue either.

    If you already have the css linked to each page your adding the header to, then why not just put the header styling into the header file that you are including. That way it will always be with the header.

    Sorry if that isn't clear enough, but all of those solutions should work for you.
     
    Raymond_M, Jan 10, 2011 IP
  7. devo10

    devo10 Active Member

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #7
    Thank you very much for everybody's help.

    I have resolved my problem.

    Thanks all of you

    Cheers
     
    devo10, Jan 13, 2011 IP