/    Sign up×
Community /Pin to ProfileBookmark

Using Same Header/Footer

How do you set up a website where there is a [B]ONE[/B] file that is the html for the whole page EXCEPT the certain pages content, and when you load up say: [B]MYPAGE.com/downloads.html[/B], it reads the first file and adds the content for the downloads page in the content area.

This would be used to ensure each page’s header/footer/navigation is the same, and if you need to change something (like the navigation links) you dont have to redo every page, just the [B]ONE[/B] page.

Could somebody help me with this?

I think it’s a .php file, but I’m not sure. I can’t find it on the internet because I dont know what it’s called.

Thank you.

to post a comment
HTML

4 Comments(s)

Copy linkTweet thisAlerts:
@ryanbutlerJan 01.2008 — Server-side include. Create a server-side page, php for example. Put only the code you want to apply to each page and then call it inside the normal pages. If you're using PHP, then you call it like:

[code=php]<?php include('path_to_file');?>[/code]

You can Google for how to call other server-side includes if using another language.
Copy linkTweet thisAlerts:
@XelenoauthorJan 02.2008 — Server-side include. Create a server-side page, php for example. Put only the code you want to apply to each page and then call it inside the normal pages. If you're using PHP, then you call it like:

[code=php]<?php include('path_to_file');?>[/code]

You can Google for how to call other server-side includes if using another language.[/QUOTE]


So on this file:

http://www.WEBSITE.com/template.php

Add this?: [code=php]<?php include('http://www.WEBSITE.com/pages/PAGE1.tpl');?>[/code]

[b]And HERE: http://www.WEBSITE.com/pages/PAGE1.tpl[/b] is the actual <html> content.

Am I correct?
Copy linkTweet thisAlerts:
@ryanbutlerJan 02.2008 — If template.php is the site layout, then yes, add the server side include call to page1.tpl, except omit the HTTP reference and just use:

[code=php]<?php include('/pages/Page1.tpl');?>[/code]

Which is a site-root relative path that will always work regardless of where you're at in the site architecture. Page1.tpl will only include the HTML content you need. Such as paragraphs, tables, lists, etc. Merely reverse it if the logic is the other way around for you.
Copy linkTweet thisAlerts:
@XelenoauthorJan 03.2008 — I ended up using two files: topframe.tpl and bottom frame.tpl

I did this:

home.php
[code=php]<?php include('home.tpl');?> [/code]


[B]AND[/B]


home.tpl
[code=php]<?php include('topframe.tpl');?>


<h1>Header 1!</h1>
<p>
CONTENT HERE!
</p>


<?php include('bottomframe.tpl');?> [/code]



I did this because there was a header AND a footer and this allowed them to fall in order with the content in the right place.


THANK YOU ryanbutler so much for your help, it really helped!
×

Success!

Help @Xeleno 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 5.20,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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