Website 3 - Add a Flat File Database


To make our 3-page website more versatile, we have created a small database. There are 2 tables, composed of text files records - 'pages' and 'blocks' which can be found in the 'data' folder.

The record formats are defined in the 'inc/db-functions' file, which also contains the functions that read, write and query this database.

Click for demo The login button is at the bottom of the page. Updates have been disabled for demo.

  3-page website with database

Block records hold chunks of text and/or images. As in the previous example, both markdown and HTML versions of the content are saved in the block record.

Blocks can also contain the HTML tags that create the page structure. These are labeled with the text 'COLUMN', so they can be distinguished from regular blocks. (You can see how this works in the 'blocks' folder below).

Each page record contains an array of blocks that will be used to build the corresponding web page on execution.


Top-level folder:

 top level file structure for NS-3a

Admin folder:

 files in admin folder for NS-3a

Data folder:

 files in data folder for NS-3a

Blocks folder:

 block files in data folder for NS-3a

Pages folder:

 page files in data folder for NS-3a

Inc folder:

 files in inc folder for NS-3a


View Code
Top-level folder:
admin-pages folder:
data folder:
data/blocks folder:
data/pages folder:
inc folder: