SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot Packetloss's Avatar
    Join Date
    Aug 2003
    Location
    Behind You
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Dynamic Site serving Static Pages?

    Hi,

    I want to create a CMS where it would store my content into the database and create an HTML static version of it with a template I create. Everytime I update it via the backend, it would update the static file. Can anyone point me into the right direction?

    Thanks in advance
    My links: [ Blog ] - [ deviantArt ]

  2. #2
    Non-Member coo_t2's Avatar
    Join Date
    Feb 2003
    Location
    Dog Street
    Posts
    1,819
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2004
    Location
    Moscow, Russia
    Posts
    147
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1)You can consider to use out-of-the-box GPL CMS TYPO3
    It has this feature and much more :-)
    www.typo3.com
    http://typo3.org/documentation/docum...lates/Publish/
    2)use you favorite CMS and HTTrack Website Copier

    Regards
    Valery
    Moscow, Russia

  4. #4
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also do a search for an article on Sitepoint by Harry Fueks about object buffering / caching.
    I have used this method for relatively simple caching jobs, and its a good intro to understand how it works.

    Basically you build your pages to serv dynamic content as you normally would, but before you script hits the DB it checks to see if the static cache file exists. If it does it just reads the contents, otherwise it will get the content from the DB and create the cache file for next time.
    When you update the content all your CMS has to do is delete the cache file, as it will be recreated the next time the relevant page is requested.

  5. #5
    SitePoint Zealot Packetloss's Avatar
    Join Date
    Aug 2003
    Location
    Behind You
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for all the help guys! If anyone else also has another method they would like to share, post them here! Thanks!
    My links: [ Blog ] - [ deviantArt ]

  6. #6
    SitePoint Enthusiast
    Join Date
    Aug 2004
    Location
    Houston, TX
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I implemented something like this, but a little differently. I store a flag in the database to indicate when the content is modified. I have a button the user clicks that re-publishes the site, but only pages that need to be modified. All pages are generated into HTML. The pages are generated by doing simple file I/O and I do it in phases.
    1. Generate any needed directories.
    2. Generate all recently modifed pages, but only a few at a time. You have to watch out for browser timeouts. If you have to generate 2,000 pages, you don't want the browser to die waiting for the script to finish. I generate a few at a time and the browser page refreshes until all pages are have been generated. As the pages are written to disk, I update the flag in the DB.
    3. Generate all index pages for each section of the site. Each section lists the most recent pages in that section.
    4. Generate the site map.
    5. Generate the home page. It lists the most recent pages from across the entire site (all sections).


    My CMS uses four basic templates. The webmaster can modify the template and insert special tokens that get replaced with actual content (AKA a simple include). An example token is #NEWS#, which the CMS replaces with the most recent 3 or 4 pages in the News section of the site.

    As I generate the pages, I write to a temporary file. After that's complete, I then rename the file to the target file name. POSIX states that a file rename is atomic. Meaning, Apache will not return an incomplete page while the site is being generated.

    Does this help?
    Last edited by Cory; Dec 23, 2004 at 08:46.

  7. #7
    SitePoint Enthusiast
    Join Date
    Aug 2004
    Location
    Houston, TX
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One other thing, you need to decide on a plan of action for how to handle deleting pages. You must remove them off the filesystem. If you don't delete them right away and wait until the site is re-published, the database will have to keep up with which pages are deleted.

  8. #8
    SitePoint Zealot Packetloss's Avatar
    Join Date
    Aug 2003
    Location
    Behind You
    Posts
    116
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks alot Cory!

    Did you have user posted comments on the site you made? What would the best way to allow users to post comments on a generated static page?
    My links: [ Blog ] - [ deviantArt ]

  9. #9
    SitePoint Enthusiast
    Join Date
    Aug 2004
    Location
    Houston, TX
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My CMS does not support user comments, but you could build it into a static page system. You could build your static pages as SHTML (Server Side Includes) pages. The comments portion could be generated into another static page, and the the article page could do an include on the comments page. This would be sort of a hybrid. The article page is primarily static. Since PHP has an include function, you can use it instead of SHTML. You might choose to generate the article page as static HTML and the comments as dynamic. At the bottom of each article page you would put a link to the dynamic comments page for that article. As users enter comments and click submit, the comments page is generated immediately. Make sure to write the new page to a temporary file associated with the session and then rename it to the target comments page.

    Your design really depends on how much traffic and server load you expect to get.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •