Create a component tag
The Component tag is used to reference the content of a component within a presentation template or element design.
[Component name=" " context="autofill" format=" " separator=" " compute=" " htmlencode=" " awareness=" " presentation=" " startPage=" " resultsPerPage=" " start=" " end=" " ]For example to assign current site area to variable url.
url = "[URLCmpnt context="autofill"]"; type="sitearea" htmlencode="false" mode="current"]";Create a component tag:
- To open the Tag Helper dialog, from a presentation template or element design field click "Insert a Tag.
- Select Component as the tag type.
- Select a component to display using the tag. This is added to the tag as the name=" " parameter:
- Click OK to add the tag to your design.
What to do next
Once we have added the tag to the design, we can also add the following parameters to the tag:
Tag parameters Details name=" " To use the library specified in the URL of the current page, use name="./item". If we specify name="./item", the library name does not appear in the presentation template or element design. The actual path is not resolved until the item is rendered. context="autofill" Only used when referencing a Component tag within a Personalization element design to display the results of a Personalization rule that searches for components. start=" " end=" " The start and end attributes are used to wrap the data returned by a tag within other tags, such as HTML. These attributes are not mandatory. format=" " Optional and can only be used with some component types:
- When referencing an image component:
- Use format="url" to only render the URL of an image component.
- Use format="tag" to render a complete image tag. The image is displayed on the rendered page. This is used by default if no format is specified.
- When referencing a file resource component:
- If the file resource is a file type that can be converted to HTML we can instead convert the file to HTML and render the converted HTML directly in the web content using the format="HTML" parameter.
Examples of supported file types include:
- word-processing documents (*.doc, *.odt)
- spreadsheets (*.xls) *
- HTML files (*.htm, *.html)
- Text files (*.txt)
Other file types may also work but we need to test them first.
Maximum Cache Size:
If the converted HTML is larger than the default cache size defined by the resourceserver.maxCacheObjectSize property in the WCM WCMConfigService service, each request containing this file is converted dynamically instead of using the cached copy. This will impact performance. We may need to increase the size of the resourceserver.maxCacheObjectSize property to support large file conversions. Before doing this, we should ensure the system has enough memory installed to cope with the increase in cache size. We could also break up the file into separate files that can be converted separately instead of increasing the cache size.
- When referencing file resource and image components:
format="mimetype" Render the mime type of a file or image. If no valid mime type can be determined then "www/unknown" is rendered. format="filename" Render the name of a file or image. format="size" Render the size of a file or image using the most appropriate unit. If the resource is smaller than 1K, then the size in bytes is rendered. If the size of the resource is less than 1MB, then the size in kilobytes is rendered. If the size is greater than or equal to 1MB, then the size is rendered in megabytes. format="size_bytes" Render the size of a file or image in bytes. format="size_KB" Render the size of a file or image in kilobytes. Use format="size_MB" Render the size of a file or image in megabytes.
- When referencing a link component:
- Use format="url" to render the full URL of a link component. For example:
/wps/wcm/myconnect/Library/SiteArea/Content
- Use format="path" to only render the site path of a link component. For example:
/Library/SiteArea/Content
- Use format="tag" to render a complete link tag. This is used by default if no format is specified. For example:
<a href="/wps/wcm/myconnect/Library/SiteArea/Content"></a>
The URL generated by the link component is fully qualified when viewed through a portal. To generate a URL that is not fully qualified use the "noprefix" option instead:
- format="noprefixurl"
- format="noprefixpath"
- format="noprefixtag"
- Use format="linktext" to render text of the link.
- When referencing date elements:
- format="DATE_SHORT"
- format="DATE_MEDIUM"
- format="DATE_LONG"
- format="DATE_FULL"
- format="DATE_TIME_SHORT"
- format="DATE_TIME_MEDIUM"
- format="DATE_TIME_LONG"
- format="DATE_TIME_FULL"
- format="TIME_SHORT"
- format="TIME_MEDIUM"
- format="TIME_LONG"
- format="TIME_FULL"
- format="DATE_SHORT_TIME_MEDIUM"
- format="DATE_SHORT_TIME_LONG"
- format="DATE_SHORT_TIME_FULL"
- format="DATE_MEDIUM_TIME_SHORT"
- format="DATE_MEDIUM_TIME_LONG"
- format="DATE_MEDIUM_TIME_FULL"
- format="DATE_LONG_TIME_SHORT"
- format="DATE_LONG_TIME_MEDIUM"
- format="DATE_LONG_TIME_FULL"
- format="DATE_FULL_TIME_SHORT"
- format="DATE_FULL_TIME_MEDIUM"
- format="DATE_FULL_TIME_LONG"
- format="RELATIVE" (The relative date is displayed as either "today", "yesterday" or the number of days ago.)
- format="MILLIS" (Number of milliseconds since Midnight, January 1, 1970 GMT)
We can also set user-defined formats for dates:
- When referencing number elements:
- We can also set user-defined formats for numbers:
- When referencing user details:
- When formatting user details, the format parameter is used to define which LDAP parameter to use when displaying user details.
- format="cn" displays the common name.
- format="dn" displays the distinguished name.
- Maximum character length:
- We can also specify a maximum number of characters to display using this format:
- format="length:number_of_characters"
To display a maximum of ten characters we would specify the following parameter:
- format="length:10"
compute=" " This is only applicable to menu, navigator, and taxonomy components. We specify compute="always" when we reference some JSP code within a component design, and we want that code to be run separately on each result returned by a menu, navigator and taxonomy component. For example, if a menu referenced JSP code that used the public DocumentId getCurrentResultId(); method, we would use compute="always" to make the JSP code run separately in every result returned by the menu. If not specified, then compute="once" is used which is the default method for delivering the results of menu, navigator, and taxonomy components. htmlencode=" " If htmlencode="true" the reserved HTML characters in text and short text components are converted into character entities. For example, '<' is converted to '<'. This is useful if to prevent users adding malicious code, or to prevent users changing the look and feel of their text using HTML. If not specified, the default setting specified by the cmpnt.htmlEncodeDefault property in the WCM WCMConfigService service is used. By default, this property is set to true. awareness=" " If awareness="true" then user names are displayed using the people awareness features. This feature displays user names as hyperlinks that allow users to contact people with whom they might want to work. Wherever person links appear, users can click the link to display a menu of actions for collaborating (contacting and working) with the person named by the link. If we, as administrator, have also configured an IBM Sametime server to work with HCL WebSphere Portal, person links indicate whether a person is active, away, offline, or in a Do Not Disturb state. If not specified, then awareness="false" and people awareness is not used. presentation="itemname" Name of a list presentation to use when displaying a navigator, menu, personalization, or search component. This will override the list presentation selected on the component itself. To use the library specified in the URL of the current page, use presentation="./item". If we specify presentation="./item", the library name is not displayed in the tag. The actual path is not resolved until the item is rendered. startPage="number" Optional and is used to set which page of results to display when a navigator, menu, personalization, or search component is first displayed. This will override the Start page value specified in the component itself. resultsPerPage="number" Optional and is used to set the number of items to display in each page of results displayed by a navigator, menu, personalization, or search component. This will override the Results per page value specified in the component itself. separator=" " This only used when referencing a user selection component. It is used to define what text or code is rendered between each selection. For example, to add a line break between each selection, we would use separator="<br>" . If not defined, a comma is placed between each selection when rendered.
Parent Create web content tags