M.Zharkikh's personal site logo
Mail to site
Print version
News (RSS)
Smereka / For designers / Sections

Smereka

For designers

Sections

Sections technique intended for designing page templates, not for individual nodes. While section included in the node HTML code, is not subject to specific treatment and will be used literally.

Section syntax

Section is a piece of HTML code, limited by a special comments:

	<!-- Begin section SectName -->
	Section code here
	<!-- End section SectName -->

After start commentary marker should be a space, then the words Begin section (case sensitive!), then the required space and the name of the section (any sequence of characters except spaces), then the space and end comment marker. End of section written by the same rules.

In the template section of the same name can be repeated (for example, the site menu can be placed in several places). Sections can contain nested sections in their code. Sections can even cross the frames of other sections (provided that such confused scheme gives a reasonable substitution code), although this approach is not recommended.

Template designed for substitution may contain several consecutive sections (eg, replacement for menus and footer). They are processed sequentially, but the nested sections are not processed separately, and treated as part of the parent section code and substituted literally.

Sections can contain any HTML code, provided that the result of substitution creates a valid HTML code. Thus, if section contains the table header or begin of the form, the section that replaced it also must contain table header or begin of the form.

Sections compilation

Section compilation occur when a page template contains reference to another (parent) template. Smereka passes through the chain of links to the root template.

The root template must provide full page code (html – /html). If the descendant template has some sections (typically), each such section displaces source code of section with the same name in parent template. If parent template contains several repetitions of this section name, all of them will be replaced (in this case used only section name, not the code).

Template formed after this step of compilation includes sections with this name and a new code (ie, during the subsequent compilation these sections can br replaced or modified again).

After substituting the first section of the descendant template, Smereka select the next root section from descendant template – until exhaustion of the root sections.

This procedure is repeated for all linked templates, and ends on the template that was caused.

Example of sections application

Consider in a simplified form section mechanism for the page you are reading.

The root template is:

<html>
…
<body>
<!-- Begin section MainBar -->
<table>
 <tr>
 <td>
 <Smereka Method="Inspector" Display="Crown" />
 </td>
 <td>
 <!-- Begin section MainCell -->
 <Smereka Func="GetDocTitle" />
 <Smereka Method="CompiledAttr" />
 <!-- End section MainCell -->
 </td>
 </tr>
</table>
<!-- End section MainBar -->
</body>
</html>

It contains three smeretags that generate a tree navigator, document title and document body. It contains two sections, one of which captures all the realm of the page, second – a table cell to the right of the tree.

To display images in the gallery we do not need a tree, we want to bring maximum area for the image instead. To do this, one create a new template, inherited from the previous one, which have next code:

<!-- Begin section MainBar -->
 <Smereka Func="GetDocTitle" />
 <Smereka Func="MakeImage" />
 <Smereka Method="CompiledAttr" />
<!-- End section MainBar -->

As a result of compiling the old section MainBar (which contained a table) will be superseded and replaced by this five lines.

If it became necessary to sell the Mercedes on the site, one can use next template inherited from the root:

<!-- Begin section MainCell -->
 <Smereka Func="GetDocTitle" />
 <Smereka Func="GetProductColor" />
 <Smereka Func="GetProductImage" />
 <Smereka Func="GetProductPrice" />
 <Smereka Method="CompiledAttr" />
 <!-- Begin section CustomerOrderForm -->
 <!-- End section CustomerOrderForm -->
<!-- End section MainCell -->

In this case the tree on the left will display categories and products, and cell MainCell is displayed information about a specific product: name – color – picture – price – description.

Our new section ends with the nested section CustomerOrderForm, currently empty. While using this template description of the product will be withdrawn, but without an order form. This is done to provide for templates, inherited from this, an opportunity to determine this form by itself.

For example, if the page is for new customers, it can contain the text «Congratulations on the purchase of your first Mercedes», and if the buyer has already signed on, he can show the form that says «Buy your 600-th Mercedes here».

This example does not contain any details of formatting – that in order to show the principle of template compiling and ways to use this mechanism to build easily controlled system of page prototypes.

Previous article | List articles | Next article

Previous section | Table of content | Next section

Please this page? Help us to develop this site!

© 1978 – 2018 N.I.Zharkikh

Reprinting of articles from site are encouraged while
reference (hyperlink) to my site is provided

Site powered by

Load count : 1587

Modified : 8.08.2017

If you look up the type error
on this page, please select it
by mouse and press Ctrl+Enter.