-
Notifications
You must be signed in to change notification settings - Fork 0
Docs MVC ViewEngines Memphis Configuration
The basic configuration for the Memphis view engine is done in config/xml/memphis.xml. Here is an example for such a configuration:
#xml <?xml version="1.0" encoding="iso-8859-1"?> <xj:configuration xmlns:xj="http://xjconf.net/XJConf" xmlns:ws="http://stubbles.net/websites" xmlns="http://stubbles.net/websites/memphis"> <config> <parts> <part name="content"/> <part name="navteasers"> <defaultElements> <ws:includeFile name="acup" source="acup.html"/> <ws:includeFile name="search" source="search.html"/> </defaultelements> </part> <part name="header"/> </parts> <frames> <frame name="default">frame/default.tmpl</frame> <frame name="popup">frame/popup.tmpl</frame> <frame name="blank">frame/blank.tmpl</frame> </frames> <metaTags> <meta name="description">This is a description.</meta> <meta name="keywords">keyword1, keyword2</meta> </metatags> </config> </xj:configuration>
Three different things are configured here: parts, frames and meta tags.
A frame is the general layout of the site. Here, three different frames are configured: a frame named default, one named popup and one named blank. As a rule of thumb, there should always be a frame named default because the Memphis view engine will fall back to this one if no special frame is requested or the requested frame does not exist. The frame/default.tmpl file names refer to template files that can be found in the templates directory.
A frame may look like this:
#xml <patTemplate:tmpl name="frame"> <html> <head> <title>Stubbles example frame for Memphis view engine</title> <meta name="Description" content="{META_DESCRIPTION}" /> <meta name="Keywords" content="{META_KEYWORDS}" /> </head> <body> <img src="data/images/stubbles.png" alt="Stubbles Logo" style="padding: 2px;"> {HEADER} {NAVTEASERS} <h1 style="font-size: 21px;">Stubbles Memphis view engine example</h1> {CONTENT} </body> </html> </pattemplate:tmpl>
Every frame needs to be a template and surrounded by patTemplate tags. The name of the outer patTemplate tag needs to be frame. (You may nest other patTemplate tags inside the frame as you like.) As you can see three different place holders have been defined in the template. These place holders refer to the defined parts.
The frame for a page is determined in several steps: first, the page configuration is checked if it has a fixed frame. Fixed means that it is not changeable which frame is used for the given page. If the frame is not fixed, the request is checked if it as a request param named frame with the value of one of the defined frame names. If this is the case this frame will be selected.
If the request does not have such a request param the session is checked if under the key net.stubbles.websites.memphis.frame a valid frame name is stored. If yes, this one is selected.
If the session does not contain such a value the page configuration is checked if it contains a property named frame. If yes, this one is selected.
If all attempts to select the correct frame failed, the Memphis view engine falls back to the frame default.
In our example three different parts are configured. For each part a place holder exists in the frame (it does not need to exist, for example in the popup frame it might not be useful to display the header or navteasers parts). In general the parts define where which content will be placed inside the frame.
Additionally it is possible to configure some default page elements which are executed on each page request. In the example above, the part navteasers will consist of the content of the files acup.html and search.html in the templates directory. For more informations about page elements see creating pages.
The content of the parts will be filled by the page elements of the selected page.
The last part defines the meta tags to be used in the frame. Here, two meta tags are defined: one for the description and one for the keywords. In the frame the contents of this tags will replace the META_* place holders. This is a convenient way of storing the meta tag contents in a general place instead of having them in each frame.