Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question easiest way to reuse a file?

    Hey,

    i'm redesigning my site and i want to create a header file once and just call it on every page. i tried using an include statement but when the file is inside another directory it seems to not work any more. for example if header file, and index file are all located in the home directory it works just fine. but when i code a sports gallery page that is located in a galleries directory, the header file doesn't work.

    any suggestions as to how to make it work???

    thanks

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    Change the path? include('../header.php');

  • #3
    New to the CF scene
    Join Date
    Jan 2007
    Posts
    8
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Inigoesdr View Post
    Change the path? include('../header.php');
    i've tried that but then it wouldn't work on the main page.

  • #4
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,043
    Thanks
    19
    Thanked 42 Times in 42 Posts
    then change them depending on the directory... simple, if is in home directory usr include(page.php);
    if its in a level above home user
    include(../page.php);


  •  

    Posting Permissions

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