Renders an anchor or image tag depending on the context

The tag command renders an anchor or image tag depending on the context.

Command: "tag"

Overview

Introduction

Use the tag command to render a link to an object or to render an image tag.

The location URLs which are used for an image's src attribute and a hyperlink's href attribute are shortened paths. This means absolute paths with protocol://hostname are cut off. This has the advantage, that the HTML page's source gets smaller (especially on pages which contain a lot of (navigational) links). If you run a site which is accessible via http as well as via https the links will always be OK.

Images are rendered with specified correct physical dimensions. You can override the physical height and/or width by specifying those attributes "by hand".

If the object specified in the obj attribute is of type e.g. ZMSRubrik or ZMSDocument a link is returned. If a (Zope)-Image object or an ZMSGraphic file is specified an IMG tag is returned.

If the object specified in the obj-attribute is a list, then tags for all its items will be rendered.

General Syntax

Command: "tag" - Attributes

Attribute "obj"

Meta type :

ZMSRubrik, ZMSDocument, ZMSGraphic, ZMSFile, Graphic, File, List of Objects mentioned

Allowed values :

Reference to any object or list of objects of the meta types mentioned above.

Specify the object which should be used as the context. If a list of objects is specified, tags for all those objects will be returned. If you additionally set the separator-attribute (see also the breadcrumbs command), its value will be used as a spearator between the rendered tags.

Attribute "prop"

Meta type :

string

Allowed values :

ZMS Attribute Names

Default Value :

None

If specified, ZMSHelper will try to find the attribute with this name. Same result as getObjProperty(prop,REQUEST). Note: this will override an optional object which can be specified in the obj attribute. This function is interesting in combination with the acquire attribute.

Attribute "acquire"

Meta type :

boolean

Allowed values :

true, false, 0, 1 or a python expression

Default Value :

false

This attribute makes only sense when the prop attribute is specified. If set to true ZMSHelper goes up the hierarchy of objects until it finds an object with the attribute set in prop which is not None or "".

Attribute "missing"

Meta type :

string

Allowed values :

any string.

Default Value :

None

This string is shown instead of an ZMSHelper error message or if the specified object or attribute returns None.

Attribute "caption"

Meta type :

string

Allowed values :

title, titleshort or any other attribute which is supported by the specified object

Default Value :

title

Specify the name of the object's (specified in the "obj" attribute) attribute which should by used for the inner html of the anchor tag.

Attribute "href"

Meta type :

ZOPE object, Python Expression or the Path as String

Allowed values :

Any of the types mentioned above.

Default Value :

None

This is an optional attribute. Set this attribute only if the object refenced in the obj-attribute is an image. If this attribute is specified the resulting IMG-tag is surrounded by an anchor-tag. If you supply an Zope object as a value, its (shortened) URL is used for the href value. But you can also supply any valid Python Expression or just a string.

Attribute "visible"

Meta type :

boolean

Allowed values :

true, false, 0 or 1

Default Value :

true

Either "true" or "false" or an expression which returns a boolean value. E.g. this expression would only show this tag on the first level of the hierarchy. visible="getLevel()==1"

Attribute "text_only"

Meta type :

boolean

Allowed values :

true, false, 0 or 1

Default Value :

false

Optional attribute. Set this if you want the code, returned by this tag to be text only. Any HTML tags will be removed.

Attribute "html_quote"

Meta type :

boolean

Allowed values :

true, false, 0 or 1

Default Value :

false

Optional attribute. Set this if you want the code, returned by this tag to be text only. Any HTML tags will be removed. Specify this attribute if you want to convert characters that have special meaning in HTML to HTML character entities. E.g. "< >" to "&lt; &gt;" etc.

Attribute "valid_tags"

Meta type :

List

Allowed values :

A list of strings.

Default Value :

None

The resulting HTML will only contain tags of the specified names. Any other will be stripped. Note: the tag names must be lowercase.

Attribute "width" or "height"

Meta type :

integer

Allowed values :

An integer specifying the height or width.

Default Value :

None

If you specify the height or width attribute when rendering an image, those values will be used instead of the physical dimensions of the image.

Attribute "alt"

Meta type :

Python Expression, string

Allowed values :

Any valid python expression which returns a string.

Default Value :

None

Sets the alt attribute of an image if the referenced object is an Image or a ZMSImage.

Attribute "force_cut_index"

Meta type :

boolean

Allowed values :

true or false

Default Value :

false

Cuts "index_eng.html" or "index_ger.html" even on a multilingual site.

Attribute "url_postfix"

Meta type :

string

Allowed values :

any string

Default Value :

""

This string is appended to each URL in the href attribute of the anchor-tag.

Command: "tag" - Samples

Display a link to the ZMS root node

This sample displays a link to the ZMS root node called content and adds a style-attribute to the A-tag.

HelperTag Syntax

Necessary DTML-code using the "Classic" Syntax

Display an image, with a hyperlink

Display the image hdr.gif located in the common folder. The tag will only be displayed on the first hierarchy level (due to the visible attribute). The IMG-tag will be surrounded by an A-tag since the href-attribute is specified. The value is set to content which is an Zope object. Its URL will be used for the the href value of the A tag.

HelperTag Syntax

Show an acquired titleimage on all pages of the subtree

This code displays <img>-tag showing the titleimage of the current ZMS folder. If the folder has no titleimage, the parent- (or parent-parent-) image is shown.

HelperTag Syntax

Render a main navigation bar

This will render a navigation bar with links to all PAGE-items of the first level separated by a red pipe symbol.

HelperTag Syntax

Render language buttons

This tag renders image tags for language icons which are physically located in the /common/lang folder. It links them with the the page in the according language, this is done by specifying the href attribute. The language icon is only shown when the expression for the visible attribute equals to true.

HelperTag Syntax