Webmaster Forum

Advertise Here   PR6 Link Building Service   V7N Directory
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Reply
 
LinkBack Thread Tools Display Modes
Old 01-22-2008, 03:41 AM   #1 (permalink)
Junior Member
 
Join Date: 05-05-07
Posts: 2
iTrader: 0 / 0%
Latest Blog:
None

WebCM is liked by many
Lightbulb [PHP] Good CMS design, templates and other issues

I hope you can spend some time and help me to select proper application design and programming issues. I'm making new version of CMS. I've been mostly theorizing about it for a recent months.

Main Goals
The main goal of this CMS is speed and performance. It should work fast on slower or overloaded servers. Other goals are: easy appearance editing, low size, care about input data (e.g. if error occurs, form is sent to client with his input)... This CMS uses PDO for communication with database.

Let's start. Front Controller?
There are some front controllers and other files in the main directory:
  • index.php - handles most requests
  • login.php - login and logout
  • adm.php - administration panel
  • request.php - handling AJAX
  • kernel.php - the most important file - connecting to database, setting user, lang, style... general functions.
  • other - e.g. go.php (downloading files, redirecting to links)
Are front controllers better solutions than seperate module files (which handle requests), e.g. art.php, image.php...?

Details of index.php
There are several versions of index.php depending on application design.
http://pastebin.com/m7795f4c0 - index.php
http://pastebin.com/m41367c82 - content.php

Problem 1. Access to <title> tag.
In previous versions, all modules were included in <body> tag by the main template. Document Title was always constant (set in configuration). However, it's better to display currently displayed subpage's title in <title> - for users and for Google. So I was forced to change something. The first action was setting it only for content modules (see it in posted URL above).

How to allow all modules to change <title> and <head>?
It's more difficult. I will explain you, why. However, let's begin from some methods of byways:
  • Output Buffering - everything what modules and their templates (included by modules) display, is buffered and assigned into $content variable. No problem with setting <title> and <head>. However, output buffering and assigning data into variable uses more RAM and may be little slower.
  • Template abstraction - all modules are included before <html>. They tell CONTENT object or class, what should be displayed. CONTENT class would offer some functions like: add(), info()... The main template displays content: <?= $content ?> (if we use __toString) or: Content::display(). Examples:
    PHP Code:
    Content::add('filename'$data);
    Content::info('information'$links); 
  • Modules abstraction - modules are covered into classes. Before <html> index.php gets <title>'s text from them. In <body> the main template calls Module::display() or prints: <?= $module ?> (if we use __toString). Unfortunately, we must use or define some global variables, e.g. $cfg, $lang, $db, maybe too: $user... Example:
    PHP Code:
    class News
    {
      
    /* some variables? */
      /* __construct(), __toString() */

  • FILE constant or $template variable - without abstraction. If FILE not defined, use $_GET['mod'] as FILE. Example:
    PHP Code:
    define('FILE''template_file.php'); 
  • Another way?
Remember that $lang and $db are used in all modules, $cfg in most, $user in some of them. They are global. What do you think about above methods and why?

What do we need to display?
In some modules we have to display only one template. However, most of them may:
  • use more templates - I think I can use include() in one of these templates
  • display only information - examples: user doesn't exist, No votes in this poll, No results. In the first case we can display 404 page instead. Sometimes we would like to put some links under the information.
  • comments - this submodule makes everything in global scope. In case of abstraction, I must cover it into class or function.

Code repetitions
There are 5 content modules - articles, files, images, links and news. 4 of them have "details" page. In every of these 4 modules we must:
- download data about item from database
- IF item exists: download data of item's category (common)
- display hierarchy of categories (common - function in kernel.php, but not good solution)
Is it a problem to repeat some fragments of code? In the beginning of creating new version (you can see it in posted fragment of index.php) index.php included common content.php file. However, adding new type of content requires more modifications or we must create something like "content" plugins.

Okay, I'm finishing this contemplation for now. I hope you will give me some advices. How would you solve my problems? Let's talk about it. If you want more examples or code of above methods, tell me. Remember that speed, performance and low RAM usage is important.
WebCM is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 01-23-2008, 12:05 AM   #2 (permalink)
v7n Mentor
 
Costin Trifan's Avatar
 
Join Date: 04-13-07
Location: Romania (atm)
Posts: 2,846
iTrader: 0 / 0%
Costin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web proCostin Trifan is a highly respected web pro
Wow! This thread will be interesting!

"gets popcorn"
__________________
Costin Trifan is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-24-2008, 07:50 PM   #3 (permalink)
v7n Mentor
 
digiweb's Avatar
 
Join Date: 04-07-06
Location: Manchester, NH
Posts: 762
iTrader: 1 / 100%
digiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of lightdigiweb is a glorious beacon of light
Send a message via Yahoo to digiweb Send a message via Skype™ to digiweb
What's the question? Is it how to add a title tag to your CMS? You have to render the head separately from the body, they should not be done in one function. They can be two methods on one object.
digiweb is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
contact form and link issues, newbie to web design mxfs779 Coding Forum 2 06-12-2007 12:01 AM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 10:44 PM.
© Copyright 2008 V7 Inc


Search Engine Optimization by vBSEO 3.1.0 ©2007, Crawlability, Inc.