Forum Moderators: phranque

Message Too Old, No Replies

Your thoughts on this concept?

A databaseless content management system

         

cgcody

7:05 am on Sep 21, 2006 (gmt 0)

10+ Year Member



First off, forgive me as I am no Web"master". I'm merely a hobbyist whom dabbles in a few subjects of web design.

Now, I have a small, personal website for my 3D artwork. As of late, I've been learning about various techniques in managing the content of the site, dynamically (I've been learning PHP). In my search for information, one thing I keep reading about is that it is a good idea to cache your dynamic pages into html files on the server when new content is requested, so as to lighten the blow of heavy traffic.

Anyway, I've been thinking that this sounds kind of redundant. Why not skip the database all together, and write new content directly to the html files? You can manage your site's content, and no traffic has to see any server side scripting or database queries.

Basically, the idea is thus:
* You have a form, in which you manage your content.
* Upon submitting the form, the script does 4 things (And 1 optional):
** 1. Call a file that contains information about the website's layout.
** 2. Inject the POST data into the proper tags of the layout.
** 3. Inject the POST data back into the value attributes of the form. (So the content can be edited later.)
** 4. Write the above data to the respective files.
** 5. Optionally, write the content to a database, only to be used for a search and/or archiving feature on the website.

Now I can see that there would be cons, but there are also pros, just as any other system would have.

Your thoughts? Any other ideas to minimize database usage, while keeping the site very manageable?

lammert

7:43 am on Sep 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



There are CMS systems working with a databaseless design. They write the data directly to a file, either in plain HTML or in a meta format which is parsed before it is served to the visitor.

The major pro is speed. This forum WebmasterWorld for example uses a databaseless design to store the posts.

The major con is flexibility. Database based CMS systems often automatically add internal menu's and link structures to the pages. You only have to write the content and when new pages are entered, the CMS system automatically categories them and makes them available in menus etc. Imagine that on an existing site with 1000 content pages you want to add a link to a new FAQ page. With a database based system this is easily done with a change in the template.

With static HTML files, you have to maintain internal linking yourself. If you want to add the FAQ page, you have to edit 1000 pages. And when you store the file in a meta format which is parsed before sending the information out to the visitor, you still need a PHP/ASP/other script to add the relevant internal linking.

Something intermediate is SSI (server side include). When writing the content files in .shtml format, you can add INCLUDE statements for common site parts like header, footer and navigation. This will give a combination of the speed of plain HTML (The parse time of SSI files is almost zero on current webserver CPUs) but you have the flexibility to change the general site template without changing the content files.

zulu_dude

8:46 am on Sep 21, 2006 (gmt 0)

10+ Year Member Top Contributors Of The Month



As Lammert said, there are several CMS systems available that already do this. If you search for 'flat file CMS', you should find a few.

cgcody

9:12 am on Sep 21, 2006 (gmt 0)

10+ Year Member



huh, I thought the idea sounded so outrageous/unorthodox, that it wouldn't have been put into practice. And here I thought I was on to something.

Well I'm still going to try and create my own databaseless CMS. It will be a good way for me to learn PHP.

And as for handling layout changes, it shouldn't be a problem. Here is a basic idea of how my script will be set up:

<?php

//Figure out which page is being edited.

ob_start(); //start buffering the content.

?>

<!-- the layout of the page being edited -->
<html>

<head>
<title>Some page</title>
</head>

<body>
<?= $_POST['content']?>
</body>

</html>

<?php

//Write the buffered content to the respective page.

$bufferContent = ob_get_contents();
ob_end_clean();

$fp = fopen ( 'somefile.html' , 'w' ) or die ( 'Error opening file' );
fwrite ( $fp , $bufferContent );
fclose( $fp );
?>


As you can see, all I would have to do is edit the html above, and the next time the form is submitted, the page would be built with the new design. I could then have an "update all" button that re-parses all pages, in the event of a layout change, though I could see where parsing 1000s of entire pages could be bad.

Thanks. :)

EDIT: I realize that I'm being specific to PHP now. The original debate was intended to be scripting language neutral.

bwnbwn

2:13 pm on Sep 25, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Dreamweaver templates work this way. A page becomes a member of the template and you click update all after you make a change.

jtara

5:46 pm on Sep 25, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Dreamweaver is basically a CMS that runs on your local machine, and produces HTML and CSS files.

A bit of history - Dreamweaver was originally written by a now-defunct company called MediaShare. I worked there around 1995. They had a product called "ProductBase" which was meant to publishing catalogs to print and CDROM. The idea was to put all the product data in a database, and then publish to multiple formats from the same database. So, from the very start, DreamWeaver was a "content management system".

Anyway, perhaps you don't want a CMS at all. If you are the only person maintaining your website, perhaps all you need is a "CMS-like" HTML editor.

Alternately, many CMSs - even those that use databases - have the ability to publish to static pages. You don't really need to get rid of the database - just to eliminate the need to hit the database when the pages are read.

cgcody

10:05 pm on Sep 25, 2006 (gmt 0)

10+ Year Member



I didn't know that about Dreamweaver. I've used DW a bit in the past, but I use HTML-Kit. It's lightweight, powerful... and affordable.

Anyway, originally I was going to use a premade CMS like Joomla!, but found most to have way too many features for my needs. Many of them also take away the joy of making perfect, strict xhtml code, laid out just the way I want it.

So being web development is a hobby of mine, I decided I would create my own custom CMS as an excuse to learn a server side script, a part of web dev I have yet to venture into. I went with PHP for various reasons, mainly the vast amount of learning material on it.

I've already learned enough to create my own, very simple, database driven CMS. The system works fine, but I guess you could say curiosity took over in trying to make the system more efficient.

In short, it all comes down to having an excuse to mess with code. :)