thunderbird
thunderbird

Reputation: 2733

Best way of storing large pre-formatted text to be displayed on a website?

I have about 21 text files with pre-formatted html content(text,images with html markup). I am creating a website that would display these text-files with the correct format. Also, the no. of files (21 files as of now) is most likely to keep on increasing. I would like some help as to

Upvotes: 2

Views: 3104

Answers (1)

Zsolt Szilagyi
Zsolt Szilagyi

Reputation: 5006

What you are creating is a so-called content management system, short cms. Wordpress, Drupal, and many others are examples.

Creating single pages is the worst idea: You will have to update them all for every change. XML is not that good either: You don´t want to parse ALL the texts to extract a single text on every visit (performance).

Although your task can be achieved by storing single text files, I advise to go with the database. As your CMS will grow, you will have the option to add further data. (E.g. you will add a meta-keywords tag, or an active/inactive-flag, a title field and so on.)

While one day you might think about caching database for performance, even on the slowest shared host MySql gracefully handles sever hundred queries per second.

EDIT: What to store in DB?

You don´t want everything in DB. Besides CSS, Images and JS being regular files (cached by browsers), you will have your header, footer and navigation in html. (Or smarty .tpl files - check it out. Not everyone likes it, I do.) What belongs into DB are the "content parts.

Ask yourself two questions:

  • If I change that part, will that change be visible on more that one page? If yes, it belongs to a layout html file.
  • If I want to give access to someone who writes my content - would I grant him access to that part? If not, it´s a layout file.

Typically, your page consists of

  • header (logo, search, login etc.)
  • navigation (categories etc.)
  • sidebar (news, gadgets, further navigation)
  • content (in database).
  • footer (link to imprint etc.)

You might want to check out some established CMS system before attempting to make your own. You might get valuable insights.

Upvotes: 6

Related Questions