Home : Introduction : Embperl 2 Advanced
Google Web perl.apache.org

 
Home
 
Features
 
Introduction
 
Embperl
 
Embperl::Object
 
Embperl 2 Advanced
 
DBIx::Recordset
 
Documentation
 
Installation
 
Download
 
Support
 
Changes
 
Wiki
 
More infos
 
Add info about Embperl
 
Login

    Stable 2.4.0
    Beta 2.5.0_3
Support the development of Embperl! More...
The Layout
[ << Prev: Introduction ] [ Content ] [ Next: Separation of Application Logic and Content >> ]



Overviewtop

The Embperl website basically is structured as follows:

 +----------------------------------------------------------+
 | base.epl                                                 |
 | +------------------------------------------------------+ |
 | | header.epl                                           | |
 | +------------------------------------------------------+ |
 |                                                          |
 | +--------------+  +------------------------------------+ |
 | | menuleft.epl |  | content.epl                        | |
 | |              |  | +-------------------+ +----------+ | |
 | |              |  | | *                 | | news.epl | | |
 | |              |  | |                   | |          | | |
 | |              |  | |                   | |          | | |
 | |              |  | |                   | |          | | |
 | |              |  | |                   | |          | | |
 | |              |  | |                   | |          | | |
 | |              |  | |                   | |          | | |
 | |              |  | |                   | |          | | |
 | |              |  | +-------------------+ +----------+ | |
 | +--------------+  +------------------------------------+ |
 |                                                          |
 | +------------------------------------------------------+ |
 | | footer.epl                                           | |
 | +------------------------------------------------------+ |
 +----------------------------------------------------------+

If a web page is requested (e.g. /index.epl, Embperl::Object first searches for the base template. In case of the Embperl website this is base.epl (name can be configured in the web server configuration), which looks like this:

    <html>
        <head>
            <title>Embperl</title>
        </head>
        <body bgcolor="#ffffff">
            [- Execute ('header.epl') -]
            <table width="100%" border="0">
                <tr>
                    <td>[- Execute ('menuleft.epl') -]</td>
                    <td>[- Execute ('content.epl')  -]</td>
                </tr>
            </table>
            [- Execute ('footer.htm') -]
        </body>
    </html>

base.epl contains several calls to Execute. In our example Execute just includes the named pages, but it is very powerful and has a long list of possible arguments.

So base.epl will include header.epl, menuleft.epl, content.epl and finally include footer.htm.

Let take a look at content.epl. It looks like this:

 <table width="100%" border="0">
     <tr>
         <td>[- Execute('*') -]</td>
         <td>[- Execute('news.epl') -]</td>
     </tr>
 </table>

It contains again calls to Execute of which one will call news.epl and the other one is special: Execute('*') includes the file initially requested from the web server, in our case /index.epl.

So we have separated the layout from the content in a way, which doesn't need any inclusion of headers, footers or menus in the files providing the content. If we want to change the content, we just have to modify one of the above mentioned files and the whole sites may have changed it's layout without great effort.

There is another advantage: On pages other then the home page, we don't want to show the news column and this can be simply done by replacing content.epl in a subdirectory. For example under the directory /pod all the documentation is located. Now we put there the file /pod/content.epl, which only contains:

    [- Execute('*') -]

What's happeing now is, that when you request a file under the /pod directory Embperl::Object uses this content.epl file and because of that, the news comlumn will not be included.

So let make an example. When you request the file /pod/doc/index.epl, which contains a list of all the documentation available, Embperl::Object first searches the base template (base.epl). It does this by walking up the directory tree, starting in the directory where the requested file is located, until it either found it or reached the document root (or the directory configured with EMBPERL_OBJECT_STOPDIR). When base.epl is found, the same search is taking place for all files that are called via Execute. This is the reason why it picks up the /pod/content.epl in this case and header.epl etc. are still taken form the same directory as before.

So what we done here is, that we have overridden content.epl in the sub directory pod.


[ << Prev: Introduction ] [ Content ] [ Next: Separation of Application Logic and Content >> ]

© 1997-2012 Gerald Richter / ecos gmbh