Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 5 of 5
  1. #1
    Senior Member kirman's Avatar
    Join Date
    May 2003
    Location
    UK England
    Posts
    765
    Member #
    1499
    Liked
    2 times
    so im looking at making my next website dynamic...

    do you simply use include? is there anything special i should know? any top tips...

    i just did this and it worked..

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    <?php include('nav.php'); ?>
    </body>
    </html>
    Why is this any better than it being static what can i do with this that i cant do with a static site? cheers
    Dream like you'll live forever. Live like you're gonna die 2morrow!

  2.  

  3. #2
    Senior Member Ganners's Avatar
    Join Date
    Feb 2011
    Location
    United Kingdom
    Posts
    415
    Member #
    27007
    Liked
    92 times
    Well, this isn't 'dynamic'. Dynamic usually refers to content being pulled from somewhere such as a database or web service and then displayed. This is just separating parts out into reusable parts.

    So yeah that's correct how you have it. The obvious advantage is that; say you have 30 pages on a website, and you want to add another menu item to the navigation bar. So without doing how you've demonstrated above, you'll have to go through each .html file and make that change. If all of your files include the same navigation bar as you have above then you only have to change the one file. So it's a sort of DRY principle in effect.
    Mark Gannaway Software Developer

    Recent Experiments
    - Backpropogation Neural Network language solving (http://ann.ganners.co.uk/)
    - Animated image to ASCII (http://google.ganners.co.uk/)
    - 3D Paper Characters (http://cybergame.ganners.co.uk/)
    - Anagram solving (http://roflol.co.uk/)

  4. #3
    Senior Member kirman's Avatar
    Join Date
    May 2003
    Location
    UK England
    Posts
    765
    Member #
    1499
    Liked
    2 times
    so what would i do to make it dynamic with respect to a database or web service? the host im looking using has wordpress built in... so that would make it dynamic wouldnt it?
    Dream like you'll live forever. Live like you're gonna die 2morrow!

  5. #4
    Senior Member Webzarus's Avatar
    Join Date
    May 2011
    Location
    South Carolina Coast
    Posts
    3,322
    Member #
    27709
    Liked
    770 times
    That's a start, the whole purpose and benefit of using includes ... Is code once, use in many places.

    Let's say you have 50+ pages on a site, by having 1 file that contains all the "header" or "footer" links, information, etc. I say a month from now you need to update off change something in one of thier sections.

    Instead of having to modify that information on 50 pages, you update the 1 file used for the include, upload it, and you're done.

    Most people that use includes like this, do nav bars, common content sections, headers, footers, search bars, etc... Some will do an include for CSS sections ( where CSS fikes are referenced ), JavaScript sections ( where JavaScripts are included ).

    I tend to do all of the above as well as "head_extra" and "foot_extra" invade the client wants to add something later, or we add on an analytics program later... Then I just update those, upload the files and done.

    Dynamic can have a lot of meanings, but the most typical is for "content" where all of you're content is actually held in a DB, and depending on variables sent in the links, conent, special nav bars, other sections are shown...

    Some sites are completely "dynamic", meaning there is actually only 1 page, but depending on links, variables, and some creative mod-rewrites on the server side, all the pages are generated as they are requested, they use includes exclusively for "displaying the common content" a template so to speak, but everything else comes from the DB when it's called, the apache mod-rewrites make the server respond with urls that appear to be sections, sub sections, categories, etc... But if you look at the server, there's actually only 1 file on the server.

  6. #5
    Senior Member kirman's Avatar
    Join Date
    May 2003
    Location
    UK England
    Posts
    765
    Member #
    1499
    Liked
    2 times
    so...for now... i have a template for my navbar, header, body and footer... and all i have to do for the other pages is make the content and just include that.. thats simple enough and if they wanted to add another page later i just change one thing on the navbar...pretty sweet

    thanks ... i will have a crack at word press first lol
    Dream like you'll live forever. Live like you're gonna die 2morrow!


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 12:32 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com