2 methods of including files sequence

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • webcm123@gmail.com

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

  • webcm123@gmail.com

    #2
    Re: 2 methods of including files sequence

    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.

    Comment

    • Toby A Inkster

      #3
      Re: 2 methods of including files sequence

      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

      Comment

      Working...