Content template

From VYRE

Jump to: navigation, search

Content Templates or Content Edit Templates are basically JSP files for displaying and/or editing information about a single content item using the Item edit using template portlet. Unify provides a powerful JSP tag library to help quickly build custom form layouts to edit all aspects of data or file items (content and metadata attributes, item and user links, taxonomy, etc.).

In Unify version 4.4 and above, you can create a Resource for a content template which will allow you to version the content template.

Contents

Overview

The content templates have many advantages, but require basic HTML/JSP knowledge. Some of the advantages are:

  • Fully customizable: The user has full control over the HTML surrounding the fields, and can use any JSP syntax available, for example to display fields based on workflow.
  • Easy maintenance: The user can move fields around much quicker, and insert fields in between other fields without having to explicitly move all other fields down.
  • Reusable: The content templates allow reference to attributes and links by name (rather than just ID), and can therefore be reused across stores and even across different installations.

The content templates also provide a new and much more user friendly way of linking to items and users.

To view/edit content templates, click the "Content Templates" node under the "Publishing" module, Found as a subfolder of the folder "files". Following is a brief description of the JSP tags available in the item content templates.

The Unify "VYRE Item" tag library

vyre-item:attribute

The following attributes can be used in this tag (one of id, externalId, name HAS to be specified):

Attribute Values Description
id The ID of the attribute
externalId The external ID of the attribute (from an attribute template)
name
id The case-insensitive name of the attribute
name
description
keywords
locale
mode
field An input form field will be displayed
element On submit, the value will be retrieved using innerHTML (or value if the element name is "input") from an HTML element (elementId attribute needs to be specified for this to work)
defaultValue A default value for the attribute. If not specified the default value specified in the attribute definition will be used.
override
true If this is "true", then the existing attribute value will be overridden by the default value.
false (default)
presentationRuleId The ID of the presentation rule to use for this attribute, if omitted the default presentation rule will be used. Works for custom attributes, and the name, description, and keywords. (since 4.3)
presentationRuleName The case-insensitive name of the presentation rule to use for this attribute, if omitted the default presentation rule will be used. Works for custom attributes, and the name, description, and keywords. Note that presentationRuleId overrides any value in this attribute. (since 4.3)
For mode field only
hidden
true Specifies whether the input field should be hidden
false (default)
label
* The label for the field, if set to 'none' then no label will be displayed
'none'
inputClass Additional class values for the HTML input (since: 4.7)
For mode element only
elementId The ID of the HTML element from which the value will be retrieved

If you want to access the url parameters for the content template and put the value in an element, you can access the param object through the content template for example passing in test via url ( http://joe/item123?test=1 ) can be accessed via ${param.test}. You can set the attribute to immediately pick up the url value by using <vyre-item:attribute name="name" mode="field" defaultValue="${param.test}"/>.

vyre-item:attribute-value

The following attributes can be used in this tag (one of id, externalId, name HAS to be specified):

Attribute Values Description
id The ID of the attribute
externalId The external ID of the attribute (from an attribute template)
name
id The case-insensitive name of the attribute
name
description
keywords
locale
creation-date
creator-name
modification-date
modifier-name
defaultValue The default value, if not specified the default value specified in the attribute definition will be used
override
true If this is "true", then the existing attribute value will be overridden by the default value.
false (default)
pattern The date pattern to use for formatting creation date and last modified date
var an optional variable name, if specified then the attribute will be stored in the variable with this name, and will not be printed out

vyre-item:primary-attribute

Works exactly like the attribute-value tag except it displays data from the primary item for secondary localized items. You must be editing the item using the edit link provided in the XML output of both lists and items.

vyre-item:upload-field

Only for file store items. The following attributes can be used in this tag:

  • required: [true/false] specifies whether a file must be uploaded or not. Note that this only applies when editing an existing item. When creating a new file store item, a file is ALWAYS required. Also note that this only works when uploading the main binary file, not any derived file.
  • type:[content/custom_thumbnail/custom_preview/service], default="content", if "service" then serviceId has to be set. *BUG if type="content" is used the file will not upload. To use the content upload type just do not include the type tag*
  • serviceId: the custom service Id that the file will be uploaded into. That custom service should not be run automatically.
  • inputClass: Additional class values for the HTML input (since: 4.7)

vyre-item:action

Template:Rellink

The following attributes can be used in this tag:

  • type: Specifies the action to be performed. This can be one of the following:
    • create - creates an item into the working index in a checked out state (locked to the user)
    • createAndCheckin - creates an item in the working index but checked in for all to access
    • createAndActivate - creates a new item and puts it straight into the active index
    • update - updates the content/metadata of the current version (working version only)
    • checkout - creates a working version checked out to the current user. This does not update any attributes the item may have.
    • checkoutAndUpdate ('since 4.6)- same as checkout, but also updates attributes.
    • checkin - same as above but in reverse, item stays in working index
    • discard - rolls back to the previous version (n.b. you will lose all changes in THIS working version)
    • delete - deletes the item; the item will then be available in Unify's recycle bin
    • activate - moves the item from the working index to the active index
    • deactivate - moves item from active index to working index, item will be checked in for all to use
    • requestTranslation - *NEEDS MORE INFO*
    • checkoutUpdateAndCheckin (since 4.3.1.8) - Creates a new working version with your changes and checks it in for all to use (does all the action in order for checkout, update and checkin)
  • alertWarning:[true/false] (since 4.3.1.8): Optional. Whether or not an alert should be displayed when trying to do an action which cannot be processed (e.g. trying to checkout when creating an item)

Note that this tag prints a javascript method call, so if you are using it inside an a href, then remember to use the "javascript:" prefix.

Also note that all of the above are never applicable at the same time. If an action is not applicable for the current item state (for example "delete" when creating a new item), then an alert message will be displayed when the action is triggered. Therefore you will need to check whether the item variable is null when deciding whether to display an action or not. The default content template has an example illustrating this.

For a more detailed description have a look at the Item workflow page.

vyre-item:taxonomy

The following attributes can be used in this tag:

  • rootIds - A comma separated list of IDs of categories that should be displayed at the first level in the tree.
  • rootPaths - A comma separated list of full paths (/paths/like/this) that should be displayed at the first level in the tree.
  • hideRestricted: Specifies whether to hide categories that the current user does not have edit access to. Available options:
    • true - (only available for renderer='xtree', deprecated). Default option for content templates; will not show categories which are restricted and the user doesn't have EDIT access to.
    • false - (only available for renderer='xtree', deprecated). Will ignore all permission settings and show complete taxonomy tree.
    • view (available for all renderers) - will show taxonomy nodes which are not restricted or those that are restricted and current user has at least view permission granted.
    • order (available for all renderers) - will show taxonomy nodes which are not restricted or those that are restricted and current user has order or edit permission granted.
    • edit (available for all renderers) - will show taxonomy nodes which are not restricted or those that are restricted and current user has edit permission granted.
  • preselectedIds - A comma separated list of IDs of categories that should be preselected.
  • preselectedPaths - A comma separated list of full paths (/paths/like/this) to categories that should be preselected.
  • localizeLabels: [true/false] - Specifies whether to localize category names or not. Localization is done in the locale the page is rendered ("render locale"). If localized key is not found the category name is used. Defaults to false.
  • hidden: [true/false] - Specifies whether to render the taxonomy tree. Defaults to false.
  • reverse - [true/false] (fixed for 4.6.3) This will alter the behaviour of the Javascript when clicking on a taxonomy tree's categories. Normally this option is turned off, so when you select a parent category, none of its children are selected, but when you select a child, all of its parents are selected all the way until the root category. If this is marked as true, when selecting a parent category all of its children will be selected as well, and selecting a child will not select its parents (though this will be done automatically in backend when form is submitted to keep the taxonomy tree consistent).
  • treeId (since Unify 4.7) - Sets the containers HTML id.
  • sorting: Specifies how the categories in the tree are sorted. Can have one of the following values:
    • none (default)
    • alphabetic_asc (deprecated since Unify 4.7)
    • alphabetic_desc (deprecated since Unify 4.7)
    • alphabetic
  • sortDirection: Specifies sort direction. Available from Unify 4.7 onwards. Can have one of the following values:
    • asc - sorts nodes in ascending order
    • desc - sorts nodes in descending order
  • sortCaseSensitivity: Specifies if the sort is case sensitive or insensitive. Available from Unify 4.7 onwards. Can have one of the following values:
    • cs - case sensitive
    • ci - case insensitive
  • sortRoots: [true/false] (since Unify 4.7) - Specifies if the root nodes should be sorted. Defaults to false.
  • renderer: (since Unify 4.7) Specifies which tree renderer to use. Can have one of the following values:
    • xtree: legacy renderer, will be used by default if no renderer is set. Deprecated.
    • vtree: Uses vtree framework to display taxonomy. The main advantage over xtree is the ability to load taxonomy on demand (using AJAX), better pluggability for programming and styling. The following attributes are applicable for when the renderer is set to vtree:
      • vtreeCookies: [true/false] - enables cookie plugin. Defaults to false.
      • vtreeCheckboxes:[true/false] - enables checkbox. Defaults to false.
      • vtreeBold: [true/false] - enables bolding plugin. Defaults to false.
      • vtreeAjax: [true/false] - enables AJAX lazy loading. Defaults to true.
      • dynamicCssClass: if specified will append CSS class value, suffixed with node id.
      • vtreePreopenSelectedNodes [true/false] - By default this is false. When this is set to true, on templates that are being used to edit an existing item, the vtree taxonomy tree will be initially opened for each node that has at least one child the the item is in. For example, if an item is taxonomized in the category /Taxonomy/Music/Rock/Punk, the tree will have the node /Taxonomy/Music/Rock fully opened.

vyre-item:item-link

The following attributes can be used in this tag (one of id OR name HAS to be specified):

Common attributes

  • id - The ID of the link definition. This will allow the contents of the other side of the link (the side that isn't the store the CET is looking in) to be returned.
  • linkTitle - The unique title of the link definition. Since Unify 4.8.
  • name - The name of the link definition (that is, the name of the other end of the link definition).
  • mode - [field/formatted] The editing mode. If set to "field", then the old drop-down list will be displayed. If set to "formatted", then XSL will be used to transform the list (and xslId or xslName MUST be specified).

Formatted attributes

  • xslId - Only for mode="formatted". The ID of the XSL stylesheet to use (this must be an item list stylesheet). NOTE: starting from Unify 4.8, this will be the legacy id as XSLs are now migrated to publishing resources. This attribute is now deprecated as we recommend using xslPath.
  • xslName - Only for mode="formatted". The name of the XSL stylesheet to use (this must be an item list stylesheet). Starting from Unify 4.8, this attribute is deprecated as we recommend using xslPath.
  • xslPath (from Unify 4.8 only) - Only for mode="formatted". Allows to specify full path to XSL including folder name, e.g. '/Others/some_xsl'
  • lightweight - [true/false] Only for mode="formatted". If false, then the full content and metadata of the linked items will be loaded. Defaults to "true". To bring back the linked items and it's content you need to specify the third level deep linkDefinitionIds (see below)
  • elementId - Only for mode="formatted". The ID of the HTML element that contains the link list.
  • loadVersionHistory - Only for mode="formatted". [true/false] if true the version history of the item will be returned. The default value is false. (since 4.3.1)
  • loadVersionContent - Only for mode="formatted". [true/false] if true the content and metadata of the versions of the item will be returned. The default value is false. (since 4.3.1)
  • linkDefinitionIds - (only for mode="formatted") allows to bring linked items of this linked item (third level links). Expects a comma separated list of link definition IDs. Since Unify 4.6.

Field attributes

  • cardinality - [one/many] Only for mode="field". Can be either "one" or "many", default is "one". Determines whether to display a multiple select box or not.
  • saveType - Only for mode="field". Specifies how to save the links. Either "replace_existing" (default) or "add_to_existing".
  • inputType - [select/detect] Only for mode="field". Specifies how to get the link values. Defaults to "select". When "detect" is specified, then the link field will be hidden and the IDs of the items to link to will be retrieved from a request parameter by the name of "link_${linkDefinitionId}".
  • firstOptionEmpty - [true/false] Only for mode="field", inputType="select", cardinality="one". Specifies whether the first option in the select list should be an empty option (default is true).
  • savedSearchId - Only for mode="field". ID of a saved search to filter the options (optional).
  • savedSearchName - Only for mode="field". Name of a saved search to filter the options (optional).
  • locale - Only for mode="field" and inputType="select" ; use this attribute to filter items in a specific locale. The possible values are: a Locale ID String ('en', 'en_US', etc.), or 'user_locale' (displays items in the same locale as the currently logged-in user) or 'site_locale' (displays items in the same locale as the site the user is currently browsing).
  • createAsActive - [true/false]. Defaults to true. When set to false, all newly created item links will be created as inactive.
  • activateCurrentLinks - [true/false]. Defaults to false. When set to true, all item links that already exist from the item being edited will be activated if they are not already. This will not update links when the save type is set to "add_to_existing".

To add actions for adding/removing linked items in the XSL, VYRE provides the following variables that can be used in the XSL style sheet:

  • $link_add_action: prints a javascript function call that opens the popup window for selecting items to link to.
  • $link_clear_action: prints a javascript function call for clearing all linked items.
  • $link_remove_functionname: prints the name of a javascript function for removing a specific linked item. See note below.
  • $linkDefinitionId: prints the ID of the current link definition.
  • $link_move_functionname: (since 4.3.1.9) prints the name of a javascript function for moving the position of a specific item link. This takes in the link definition id, the id of the item thats position is being moved and the new position to move the item too. The positions are indexed from 0.

When printing an action to remove a single item from a list of linked items, something along the lines of the following should be used in the XSL:

href="javascript:{$link_remove_functionname}('{$linkDefinitionId}', '{@id}')"

Where {@id} is an XPath reference to the ID of the current item.

For more details on how to use javascript to link items in content templates read this article on Adding/removing linked items using hyperlinks

See Also

Code example To create a link with a known specific link ID and linked item, in your CET you could use:

<vyre-item:item-link mode="field" id="1" inputType="detect"/>

which will generate:

<input type="hidden" value="" name="item_link_1" id="item_link_1">

Then simply use JS to fill in the linked item

vyre-item:user-link

The following attributes can be used in this tag (one of id, name HAS to be specified):

  • id - The ID of the link definition.
  • name - The name of the link definition (that is, the name of the other end of the link definition).
  • mode - [field/formatted] The editing mode. If set to "field", then the old drop-down list will be displayed. If set to "formatted", then XSL will be used to transform the list (and xslId or xslName MUST be specified).
  • xslId - Only for mode="formatted". The ID of the XSL stylesheet to use (this must be a user list stylesheet). Deprecated since Unify 4.8 in favour of xslPath.
  • xslName - Only for mode="formatted". The name of the XSL stylesheet to use (this must be a user list stylesheet). Deprecated since Unify 4.8 in favour of xslPath.
  • xslPath (from Unify 4.8 only) - Only for mode="formatted". Allows to specify full path to XSL including folder name, e.g. '/Others/some_xsl'.
  • elementId - Only for mode="formatted". The ID of the HTML element that contains the link list.
  • cardinality - [one/many] Only for mode="field". Can be either "one" or "many", default is "one". Determines whether to display a multiple select box or not.
  • saveType - Only for mode="field". Specifies how to save the links. Either "replace_existing" (default) or "add_to_existing".
  • loadItemLinks - [true/false] Only for mode="formatted". If true, then the linked items will be loaded. Defaults to "false". (since 4.5)
  • loadLinkedContentAndMetadata - [true/false] Only for mode="formatted". If true, then the content and metadata for the linked items will be loaded. Defaults to "false". (since 4.5)
  • inputType - [select/detect_user/detect_parameter] Only for mode="field". Specifies how to get the link values. Defaults to "select". When "detect_parameter" is specified, then the link field will be hidden and the IDs of the users to link to will be retrieved from a request parameter by the name of "link_${linkDefinitionId}". When "detect_user" is specified, then the ID of the user currently logged in will be used.
  • firstOptionEmpty - [true/false] Only for mode="field", inputType="select", cardinality="one". Specifies whether the first option in the select list should be an empty option (default is true).
  • groupId - Only for mode="field". ID of a group to filter the options (optional).
  • groupName - Only for mode="field". Name of a group to filter the options (optional).
  • profileGroupId - Only for mode="field". ID of a profile group to filter the options (optional).
  • profileGroupName - Only for mode="field". Name of a profile group to filter the options (optional).
  • optionDisplay - (since 4.5.0.1) Only for mode="field". Optional expression used to display the user options in the select box. Uses velocity syntax, available variables are user, profile and properties (a map). When this is empty the displayed value for a user will be their full name. An example of what can be used for this attribute is

optionDisplay="FullName:$user.fullName - Employer:#if ( $properties.keySet().contains('user.employer') ) $properties.get('user.employer') #else Unemployed #end" Which will display the users full name followed by their employer if they have one.

To add actions for adding/removing linked items in the XSL, VYRE provides the following variables that can be used in the XSL style sheet:

  • $link_add_action: prints a javascript function call that opens the popup window for selecting users to link to.
  • $link_clear_action: prints a javascript function call for clearing all linked users.
  • $link_remove_functionname: prints the name of a javascript function for removing a specific linked user. See note below.
  • $linkDefinitionId: prints the ID of the current link definition.

When printing an action to remove a single user from a list of linked items, something along the lines of the following should be used in the XSL:

href="javascript:{$link_remove_functionname}('{$linkDefinitionId}', '{@profile-id}')"

Where {@profile-id} is an XPath reference to the Profile ID of the current user.

See Also

vyre-item:profile-group-link

The following attributes can be used in this tag:

  • cardinality - Can be either "one" or "many", default is "one". Determines whether to display a multiple select box or not.

vyre-item:item-list

This tag lists items linked ("listed") from current item, if the current item is the descriptor item.

The following attributes can be used in this tag (one of id or name HAS to be specified):

  • id - The ID of the item list definition.
  • name - The name of the item list definition.
  • xslId - The ID of the XSL stylesheet to use. Deprecated since Unify 4.8 in favour of xslPath.
  • xslName - The name of the XSL stylesheet to use. Deprecated since Unify 4.8 in favour of xslPath.
  • xslPath (from Unify 4.8 only) - Allows to specify full path to XSL including folder name, e.g. '/Others/some_xsl'.
  • lightweight - If false, then the full content and metadata of the listed items will be loaded. Defaults to "true".

Item-List is treated as 'formatted', so you can't use mode="formatted".

To add actions for adding/removing listed items in the XSL, VYRE provides the following variables that can be used in the XSL style sheet:

  • $item_list_definition_id: prints the ID of the current item list definition.

vyre-item:captcha-image (since 4.3)

This tag prints a CAPTCHA image, which can be used to prevent bot spamming. You will need to use the vyre-item:captcha-input as well to validate. The following attributes can be used in this tag:

  • cssClass - name of a CSS class to use for the image tag, defaults to "captchaImage"

vyre-item:captcha-input (since 4.3)

This tag prints a CAPTCHA input box, where the user enters the text displayed by the vyre-item:captcha-image. The following attributes can be used in this tag:

  • cssClass - name of a CSS class to use for the image tag, defaults to "captchaInput"

vyre-item:include (since 4.4)

This tag allows to include another resource (content template, bulk edit template, search template, static code, etc.) inside current template.

  • templateId - the id of the template to include (must be a number).

(since Unify 4.6.3) templates can be referenced on a name basis. Please be aware that template titles should be unique per type, though this is not enforced when creating them in Unify (for example, within Bulk Edit templates no two templates should have the same title, as there are no guarantees as to which one will be returned here). Also need to be careful which type of templates are included within which ones, as not all combinations work (this is due to context variables not being set appropriately). The way of including other templates is by specifying their type and title:

  • bulkEditTemplate - the title of the bulk edit template to include.
  • contentTemplate - the title of the content template to include.
  • jspResource - the title of the JSP code resource to include.
  • searchTemplate - the title of the search template to include.

vyre-item:message (since 4.4)

This tag, if included, sends an email message, as defined in Message templates. Please note that this tag will only send message when item is defined in the URL (e.g. ..../yourpage/item1234).

  • msgTemplateId - the id of the template to use for sending (must be a number). Deprecated in favour of title since Unify 4.8.
  • title - the title of the template (since Unify 4.8).

Localization

Localization values are used as follows:

<fmt:message key="my.locale.key"/>

Ensure that you import the JSTL formatting tag library by including the following line:

<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> 

Portal attributes

Portal attributes such as the context path can be retrieved and used as variables as follows:

<%
 request.setAttribute("contextPath", vyre.publishing.portal.PortalAttributes.getInstance().getPortalContextPath());
%>
  • ${contextPath}

Including another content template

Template:Rellink

See Also

Personal tools