469,133 Members | 1,003 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,133 developers. It's quick & easy.

2 methods of including files sequence

I'm making some changes in files structure in my CMS. I will use more
templates for modules. However, the topic of <titleand other ...
came back when i was thinking about it.

---- Pre-generating (A) ----

It uses output buffering. Modules files are included before <html>.
The whole middle output (e.g. article with comment, registration
form) is stored in RAM (or SWAP :D) and prepared for putting it into
the main layout inside <body>. Menus aren't stored in "output
buffering" memory.

Advantage:
:: <titleand <headcontent may be set using variables

Disadvantage:
:: Wideli (significantly) more RAM usage (e.g. 10 simultaneous
requests for 50 kb = 500 kb).
---- Generating step-by-step ----

All modules are included from the main layout from PHP basing on MOD
constant defined by index.php. However, there is additional file for
"content" modules (articles, files, images, free subpages and news) -
content.php - which gets data from database (about their category
also) and sets <titleif user have access to them. For another
modules, index.php sets <titleautomatically if $lang['module_name']
exists, e.g. $lang['users']. Perhaps, "View user: anonymous" title
isn't as important.

Advantage:
:: Lower RAM usage (big contents aren't stored twice)

Disadvantage:
:: Most modules can't access <headcontent

Some people often avoid items in Google if they can't see bold title.
However, does it concern other modules than "content" modules (e.g.
user - username, poll - pollname, news archive)?

Jun 23 '07 #1
2 1310
There is also another way to make all modules (or choosen) access to
<titleand <head>. Index.php includes one file before <html(which
gets data and sets <titleand other <headfiles). That file also
defines MOD constant.
The main layout included by index.php in <bodyincludes other file
(defined in MOD constant) which displays data.

Advantages:
:: Less memory usage
:: All modules (or choosen) can access <titleand <head>

Disadvantages:
:: More files (the second in <bodyrather must contain PHP)
:: Sometimes modules needs to show an information only. Including
additional file for doing only it is impractical.
However, if <title>s like "Show user: [username]", "Poll:
[pollname]" (I can add POLL module to including before <htmlbecause
I have to include other file with PHP code too), "Archive from 1st
May", "Private messages: folder Inbox" aren't so needed for users or
search engines, I think that "generating step-by-step" method isn't
very bad.

What do you think about it? The main goal of this CMS is speed,
performance and low RAM usage. People say that output buffering is
slow and developed for other usages than it.

Jun 23 '07 #2
webcm123 wrote:
I'm making some changes in files structure in my CMS. I will use more
templates for modules. However, the topic of <titleand other ...
came back when i was thinking about it.
Personally, my modules are PHP objects which must implement some particular
plugin interface which is defined by the CMS. (There are several different
interfaces depending on what the plugin is supposed to do, but I'm going
to describe the "panel" interface, which allows a plugin to add a piece of
content, including a title, to the page.)

object SomePanel
{
public function get_title()
{
// ...
}

public function get_body()
{
// ...
}
}

At the start, the CMS will create a SomePanel object:

require 'plugins/SomePanel.php';
$obj = new SomePanel;

Then when it needs to find the panel's title:

$title = $obj->get_title();

and when it needs to output the panel's body:

echo $obj->get_body();

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 3 days, 11:48.]

A New Look for TobyInkster.co.uk
http://tobyinkster.co.uk/blog/2007/06/22/new-look/
Jun 24 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

35 posts views Thread by Raymond Hettinger | last post: by
99 posts views Thread by David MacQuigg | last post: by
18 posts views Thread by John M. Gabriele | last post: by
reply views Thread by Leslaw Bieniasz | last post: by
3 posts views Thread by Alan Mok | last post: by
12 posts views Thread by Andrew Poulos | last post: by
11 posts views Thread by s99999999s2003 | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.