/    Sign up×
Community /Pin to ProfileBookmark

rebuilding page, includes help

right now there is a header and footer built onto every page onthe site, and about 50 pages. on the header of alot of the pages, the font got changed. i want to siwtch every page and use php include for the header and footer so that i only need one page for each, and it wuld make making changes easier. is there any easy way to go about thois that anyone can recomend? ive never actually gone about using php includes b4. any help wuld b greatly appreciated.

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJul 30.2006 — It's really pretty simple. (There's many things we could do to make it more complicated, but let's keep it simple for now.)

  • 1. Create a directory called "includes" in your base web directory (public_html, www, or whatever it's called).


  • 2. In that directory, create a file with the text you want for the header section; let's call it "header.inc". Then create a file for the footer text, called "footer.inc". (The suffix doesn't really matter, so I'm using ".inc" to make it obvious they're intended to be includes.)


  • 3. At the point in your pages where you want the header text to appear, type:
    [code=php]
    <?php include $_SERVER['DOCUMENT_ROOT']."/includes/header.inc"; ?>
    [/code]

    Similarly, where you want the footer text:
    [code=php]
    <?php include $_SERVER['DOCUMENT_ROOT']."/includes/footer.inc"; ?>
    [/code]

    Note that for this to work, you'll probably have to either rename the pages that do these includes to have a ".php" suffix, or else edit/create a .htaccess file (assuming you're on an Apache webserver) to specify that .html files must also be sent to the PHP parser.
  • Copy linkTweet thisAlerts:
    @sitehatcheryJul 30.2006 — Also, if you're talking about a simple way to replace the code with include statements on all 50 pages, you could use something like Notepad++, Crimson Editor, or Dreamweaver and do a find and replace on these code blocks which are identical on each of the 50 pages. But, before you do this, make sure you back up your files.
    ×

    Success!

    Help @tyfobpo spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 4.27,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...