Shapeshifter

Contact

PDF-ikonen

View page as PDF

Stream templates / patterns

Stream templates allows you to create various content layouts, by writing examples of what you want to achieve.

A stream pattern has a basic structure, consisting of the optional parts

- a head

- a stream

- a foot

These are inside an <element> tag

The blogs_admin template

Each template / pattern consists of one or several <element>:s

<xml>
    <element>
        <type>sections</type>

The element <type> can either be sections or entries, this tells the system to either look for section definitions (the blog, forum or site structure), or entry (the actual contents) definitions.

The <sectionHeader> is created once, at the top of the stream. The <text> tag tells the system to write that text as the header.

        <sectionHeader>
            <h2>
                <text>Blogs</text>
            </h2>
        </sectionHeader>

The <stream> is created once for each section (or entry) found, at the current position in the site. The <data> tag tells the system to look for contents in the entry data structure. For instance, the title tag. Thus, the stream below will display a list of section titles, with a checkblox, inside a <h3> tag. In this case, it will be a list of all blogs.

        <stream>
            <h3>
                <a>
                    <data>title</data>
                </a>
                <input type="checkbox" name="resource" value="no"/>
            </h3>
        </stream>

The <sectionFoot> is also created once, for each stream.

        <sectionFoot>
            <fieldset>
                <legend>
                    <text>Admin</text>
                </legend>
                <p>
                    <input type="checkbox" name="adminaction" value="Remove_All_Conferences"/>
                    <text>Remove all blogs</text>
                </p>
                <p>
                    <input type="checkbox" name="adminaction" value="Remove Selected Conferences"/>
                    <text>Remove selected bonferences</text>
                </p>
                <p>
                    <input type="submit" name="action" value="Remove"/>
                </p>
            </fieldset>
            <div class="row">
                <span class="label">
                    <text>Title:</text>
                </span>
                <spc/>
                <span class="formw">
                    <input type="text" name="conferencename" size="30"/>
                </span>
            </div>
            <div class="row">
                <span class="formw">
                    <input type="submit" name="action" value="Create Conference"/>
                </span>
            </div>
        </sectionFoot>
    </element>
</xml>

The oneblogoverview template

This template renders a classic Blog. It is not as complicated as it might seem, when you first look at it.

<xml>
    <element>

The entry type, says that entries should be used to get data.

        <type>entries</type>

We define a header, with a welcome text for the Blog

        <sectionHeader>
            <h1>
                <text>Welcome to</text>
                <spc/>

Several special data types are specified in the twinstreamraw.xq xquery file. One is the sectionTitle, which takes takes the title tag from the section associated with a particular content.

                <data>sectionTitle</data>
            </h1>
        </sectionHeader>
    </element>

The first element had only a header. Now, we define the actual stream of entries.

    <element>
        <type>entries</type>

We sort by date, so that the most recent entry comes first.

        <sort>date/raw</sort>

We create sections, by date, so that entries are grouped by the date/raw tag.

        <sectionize>yyyy-mm-dd</sectionize>

Each section gets the date of the entries in it as header.

        <sectionHeader>
            <h1>
                <data>yyyy-mm-dd</data>
            </h1>
        </sectionHeader>

We include subsections to the current position in the hierarchy, but we take only the first entry (all other entries are comments).

        <stream include="subsections" streamposition="1">
            <h2>

We present the topic name

                <data>topic</data>
            </h2>
            <p>

We present the date

                <data>yyyy-mm-dd</data>

A white space

                <spc/>

The time

                <data>digital</data>
            </p>
            <p>

The blog entry

                <data>body</data>
            </p>
            <p>

The author of the entry

            <text>written by</text><spc/><data>heading</data>
            </p>
            <h3>
                <a>
                    <text>[</text>

The number of entries, subtracting one. That is the number of comments.

                    <data>entrycount - 1</data>
                    <text>]</text>
                </a>
                <spc/>
                <text>comments in</text>
                <spc/>

The name of the section that the entry belongs to, and a link to it.

                <a href="../">
                    <data>../topic</data>
                </a>
            </h3>
        </stream>
    </element>
</xml>

Main menu bar