Casey Dwayne
Casey Dwayne

Reputation: 2169

What's the best way to load content?

Right now, the basic structure of my site is pretty bulky.

I know little about php, but I've managed to get by.

So, I was wondering - what's the best way to load content?

Right now, I have all of my pages saved with .php, using some include() and require().

I'm about to go through and update it using a php model, but I want to be sure I do it right.

So.. I'm going to be linking my keywords, description, other METAs into my database. Seems less hectic that way. Any words of wisdom before I go breaking into my massive site?

Right now:

The new version is more like

Maybe it's easier to just have 30+ separate pages with a few lines in each than generate pages dynamically? I want the content to be easy to edit.

Thanks for the help! *(sorry if it's confusing at all).

Upvotes: 1

Views: 179

Answers (1)

damoiser
damoiser

Reputation: 6238

Even in developing website, you must ever thinking about:

  • maintain your code DRY (dont repeat yourself)
  • encapsulate the ridondant code in some default structures (as programming oriented objects)

depending of the content that your site must show, the option (as you say) "30+ separate pages with few lines" is the best according to the 2 rules described above.

This let you the possibility to edit the website "speedly", e.g. if you want to edit the header, you must edit only one .php file and all the pages affects the edit. In other case, if you want to edit the content of the page "X" you can go directly to this page and edit the content.

Rememeber: try to have file that are bested implemented for the work that it must do, e.g. (something like that):

  • head.php (all that are in the head tag)
  • header.php (top of the page)
  • menu.php (the menu)
  • banner.php, banner1.php (something that are different between pages, but static itself as banners)
  • sidebar.php (the sidebar)
  • footer.php (bottom of the page)

Doing this, in 4-5 require/include you can build simply a new page.

Otherwise try to avoid pages that are re-used only one time.

Upvotes: 2

Related Questions