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

Discussion in 'Web Design, HTML And CSS' started by chicubswally, Jul 27, 2007.

  1. chicubswally

    chicubswally New Member

    Joined:
    Jul 27, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    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.
     
  3. chicubswally

    chicubswally New Member

    Joined:
    Jul 27, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    But how do I do this? Could someone give me an example please?

    Thanks!

     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    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.
     
  5. chicubswally

    chicubswally New Member

    Joined:
    Jul 27, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Newbie...
    Sorry, don't know what a template file or php is... could you help by elaborating (example) please. Thanks
     
  6. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    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.
     
  7. chicubswally

    chicubswally New Member

    Joined:
    Jul 27, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    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!
     
  8. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    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.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice