2 methods of including files sequence

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I'm making some changes in files structure in my CMS. I will use more
templates for modules. However, the topic of <title> and 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.

:: <title> and <head> content may be set using variables

:: 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 <title> if user have access to them. For another
modules, index.php sets <title> automatically if $lang['module_name']
exists, e.g. $lang['users']. Perhaps, "View user: anonymous" title
isn't as important.

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

:: Most modules can't access <head> content

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)?

Re: 2 methods of including files sequence

There is also another way to make all modules (or choosen) access to
<title> and <head>. Index.php includes one file before <html> (which
gets data and sets <title> and other <head> files). That file also
defines MOD constant.
The main layout included by index.php in <body> includes other file
(defined in MOD constant) which displays data.

:: Less memory usage
:: All modules (or choosen) can access <title> and <head>

:: More files (the second in <body> rather 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 <html> because
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.

Re: 2 methods of including files sequence

webcm123 wrote:

Quoted text here. Click to load 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

Site Timeline