Table of Contents
Text and structural elements are added to a document's body using the MU_XML_Element::add_element() method. This method takes the following format:
The first argument is the type of element to be created. The second argument, an array of attributes, is not required for some elements. In those cases, a null can be substituted. The third argument, the element's content, can be either a string or an array of strings or other elements:
Sometimes it is necessary to create "un-enclosed" elements- elements with no parent. These are useful when you wish to include an element inside another element's content. For example, you might wish for a paragraph element to contain styled text or a link. The mu_make_element() function performs this role:
Its syntax is the same as the MU_XML_Element::add_element() method.
If you are familiar with HTML, you may notice that many of the following examples require more keystrokes than their HTML equivalents. In exchange for making a lot of extremely difficult tasks easy, Marmot makes some extremely simple tasks slightly more complicated in order to separate program logic from appearance.
Examples of all of these elements can be seen in the example "Text and Structural Elements" included with Marmot.
Text elements are elements that contain only text, links, or styles. They are not concerned with a document's structure.
The simplest text element is the paragraph. It is used to add a paragraph of text to a document.
The link element is used to add a hyperlink to a document.
Links can be inserted inline into other elements:
The link's URL can be relative or absolute:
A target can be specified for a link:
A link can be opened in a popup window:
If Javascript is not available on the client's browser, the width and height attributes will not have any effect.
The style element is used to apply a CSS style to text or another element. Style elements are almost always inserted using the mu_make_element() function:
Marmot provides a few common styles:
strong
emphasis
error
sourcecode
The programmer can call on an additional application-specific CSS file. To do so, specify the CSS file in the application's calls to MU_Presentation::display():
Images can be inserted into a document with the image element:
Note: Marmot requires that all images have "alt" attributes. This attribute is meant to contain a text description of the image.
The break element is used to insert a newline. Break elements are almost always inserted using the mu_make_element() function: