473,394 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Good CMS design, templates and other issues

1
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().
  • 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 [color=red]must use or define some global variables[/color], e.g. $cfg, $lang, $db, maybe too: $user...
  • FILE constant or $template variable - without abstraction
  • 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. :)
Jan 22 '08 #1
0 1444

Sign in to post your reply or Sign up for a free account.

Similar topics

24
by: matty | last post by:
Go away for a few days and you miss it all... A few opinions... Programming is a craft more than an art (software engineering, not black magic) and as such, is about writing code that works,...
43
by: grz02 | last post by:
Hi, Im an experienced database+software designer and developer, but, unfortunately, anything to do with web-programming and web-systems designs is still a pretty new area to me... (been working...
9
by: Sebastian Faust | last post by:
Hi, I have a design problem about which I am thinking now for a while and still couldnt find any help in deja. What I need is something like a virtual function template. I know that this is not...
72
by: E. Robert Tisdale | last post by:
What makes a good C/C++ programmer? Would you be surprised if I told you that it has almost nothing to do with your knowledge of C or C++? There isn't much difference in productivity, for...
10
by: Alan Silver | last post by:
Hello, I discovered the MSDN design templates yesterday and have been looking at them. I have a problem with the Personal template. I don't have SQL Server Express loaded, as I already have...
24
by: Gaijinco | last post by:
I found one of that problems all of us have solve when they begin programming: given 3 numbers print the greater and the lesser one of the set. I was trying to remember the if-then-else...
35
by: Steven T. Hatton | last post by:
Perhaps I'm just a bit frustrated, and I will soon realize the clear truth of the matter, but right now I have some serious misgivings about the value of investing a lot of time and effort into...
48
by: Tony | last post by:
How much bloat does the STL produce? Is it a good design wrt code bloat? Do implementations vary much? Tony
1
by: PaulH | last post by:
Just announcing the news in the spirit of the News-groups: Artisteer - Web and Blog Design Automation Software Unveiled at BlogWorld Expo Ground-breaking Software Instantly Creates...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.