Newbie ?- Best method using repeating source on mult. pages

chicubswally's Avatar
Newbie Member
Hello all,
Great forum! It seems there are many experts here.

This might be a quick question someone could easily answer.

I have exactly the same code in many of my web site's pages. It's navigation bar code.

Would it be best to store this in another file and bring it into each page with just a couple of similar lines of code in each page?

Thanks in advance for your advice.

Wally
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
That would be one of the better option. Other option could be to have a template based and fetch the header / navigation for each page and if some pages don't need it you can avoid the fetching for that page.
0
chicubswally's Avatar
Newbie Member
But how do I do this? Could someone give me an example please?

Thanks!

Quote:
Originally Posted by shabbir
That would be one of the better option. Other option could be to have a template based and fetch the header / navigation for each page and if some pages don't need it you can avoid the fetching for that page.
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Say you have templates and read the content of the template file from the xyz.php based on the requirement and build on the html of the pages.
0
chicubswally's Avatar
Newbie Member
Newbie...
Sorry, don't know what a template file or php is... could you help by elaborating (example) please. Thanks
Quote:
Originally Posted by shabbir
Say you have templates and read the content of the template file from the xyz.php based on the requirement and build on the html of the pages.
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
A template file is some file which has some html code in it.

Say I have 2 files
header.html
body.html
footer.html

Which contains the specific html content for the header, body and footer respectively and based on the requirement you can get the content of the file and append it to the page as and when needed.
0
chicubswally's Avatar
Newbie Member
Is this a cut and paste process?

Where you specify body.html, I have several 'main' pages of bodies......
If I had a main1.html, main2.html, and main3.html for example, would I cut and paste the header and footers into these three documents?

Thank you again!
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
How simple or complex your case would be is upto your initial design but it should be simple segregation of html and web server language as far as I can see it.