The portaltemplate defines the basic layout of the portal page and the portlets that are rendered in the portal page. In most cases, the portaltemplate is a HTML page that is extended by special Gentics Portal.Node3 XML tags. The portaltemplate will be loaded at the start of the portal's webapplication. If changes have been made in the portaltemplate the portal's webapplication has to be restarted.
The pportal tag contains the styledefintion of the frames that encapsulate the content of the different portlets.
Example 4.53. Syntax of the pportal tag
<pportal> <modulestyles default="..."> <modulestyle id="..." actionstyle="..."> <framestyle> <windowstate>...</windowstate> ... <frame>...</frame> </framestyle> ... </modulestyle> ... </modulestyles> <actionstyles> <actionstyle name="..."> <actiontemplate>...</actiontemplate> <actionseperator>...</actionseperator> <action type="..."> <icon>...</icon> <alt>...</alt> </action> ... </actionstyle> </actionstyles> </pportal>
Table 4.166. Parameters of the pportal-tag
Name | Type | Description |
---|---|---|
modulestyles | Structure | Definition of the modulestyles. |
modulestyles.default | String | Id of the default modulestyle. If not set, the first defined modulestyle will be the default. |
modulestyle | Structure | Definition of a single modulestyle |
modulestyle.id | String | Id of the modulestyle. |
modulestyle.actionstyle | String | Id of the actionstyle to be used with this modulestyle. |
framestyle | Structure | Definition of how a portlet frame shall be rendered for specific windowstates. Each modulestyle may contain multiple framestyles (for different windowstates). |
framestyle.windowstate | String | Windowstate for which this framestyle shall be used. May be one of maximized , normal or minimized .
The same framestyle may be used for multiple windowstates (more than one <windowstate> -Node in the framestyle definition).
|
framestyle.frame | String | Template for the portlet frame. May contain the following placeholders:
|
actionstyles | Structure | Definition of how icons for window actions are rendered. The window actions include icons for switching windowstates and portletmodes. |
actionstyle | Structure | Definition of a single actionstyle. |
actionstyle.name | String | Id of the actionstyle. |
actiontemplate | String | Template for an icon for a window action. May contain the following placeholders:
|
actionseperator | String | Template for the separator to be rendered between action icons. |
action | Structure | Definition for a specific portlet window action. |
action.type | String |
Definition of the action for which this style shall be used. This may be |
action.icon | String | Definition of the action icon that will be rendered into <icon> from the actiontemplate. |
action.alt | String | Descriptive alt-text of the action. |
To define a custom action which can be used for a pnode/pbox and be catched in a reaction you need to follow the following three simple steps:
Create a new action in the actionstyles / actionstyle tag:
<action type="CustomAction"> <icon>edit</icon> <!-- Select a custom icon here --> <alt>New Custom Action</alt> </action>
Add the action to your pnode/pbox:
<action name="CustomAction"> <visible>true</visible> </action>
Use a reaction in your pnode/pbox to catch this action:
<reaction event="portal.pboxes.SimpleViewTest.onCustomAction"> <!-- do whatever you want here ... --> </reaction>
The portaltemplate may contain <pnode> tags, each one
defining an instance of a portlet with optional parameters and
customized templates. Each <pnode> implicitly defines
also a pbox
with the same id. For details on
pboxes see Section 11.1.4, “PBoxes”
.
Example 4.54. Syntax of a pnode tag
<pnode type="..." id="..."> <style>...</style> <isvisible>[<prule>...</prule>]</isvisible> <windowstate>...</windowstate> <title>...</title> <titleaction>...</titleaction> <actions> <action name="..."> <visible>[<prule>...</prule>]</visible> </action> ... </actions> <reactions> <reaction event="..."> ... </reaction> ... </reactions> <parameters> <parameter name="...">[<pobject>...</pobject>]</parameter> ... </parameters> <templates> </templates> </pnode>
Table 4.167. Parameters of the pnode tag
Name | Type | Default | Description |
---|---|---|---|
pnode | Structure | Definition of a portlet instance. | |
pnode.type | String | (required) |
portlet-name
of the portlet to be
instantiated. |
pnode.id | String | (required) | Id of the portlet instance. Must be unique within all <pnode>s and <pbox>es in this portalpage. |
style | String | default modulestyle. See Section 11.1.2, “pportal Tag” . | Modulestyle of the portletinstance. |
isvisible | Boolean or PRule | true | Whether the implicit pbox shall be visible or not. |
windowstate | String | normal | Initial windowstate in which the pbox shall be rendered. |
title | String | title of the
portlet defined in the portlet
descriptor. | Title of the portlet. |
titleaction | String | NULL | Action to be activated upon link on the portlets title. |
actions | Structure | NULL | Definition of the portlet window actions. |
action | Structure | NULL | Definition of a portlet window action. This may also override the default actions for switching portletmodes and windowstates. |
action.name | String | (required) | Name of the portlet window action. See
Section 11.1.2, “pportal Tag”
for details on action names for the
standard actions. Custom actions will
trigger an event called
portal.pboxes.[pboxid].on[ActionName]
when activated. |
action.visible | Boolean or PRule | true | Whether the action icon shall be visible or not. |
reactions | Structure | NULL | Definitions of reactions. |
reaction | Structure | NULL | Definition of a reaction on a specific event. The node value may consist of one or more lines, each one setting a portal property. See Section 7, “Property Setters” for details - reaction property setter have the limitation that you must not use quotes ("). |
reaction.event | String | (required) | Full path of the event this reaction
shall listen to. The path begins with
|
parameters | Structure | NULL | Definition of parameters for the portlet instance. |
parameter | various | NULL |
Definition of a specific parameter. The allowed values depend on the parameter definition in the Gentics portlet descriptor. You can use <pobject> to access portal properties, see Section 8, “Portal Property Paths” for more details. |
parameter.name | String | (required) | Name of the parameter to set. |
templates | Structure | NULL | Definition of specific templates for this portlet instance. See Section 8.7.4, “Template definitions” for details on definition of templates. |
The portaltemplate may contain <pbox> tags, each one defining a place where a portlet may be rendered. The difference between a <pnode> tag and a <pbox> tag is that with a <pbox> does not create a new instance of a portlet.
Example 4.55. Syntax of a pbox tag
<pbox id="..."> <moduleid>...</moduleid> <windowstate>...</windowstate> <isvisible>[<prule>...</prule>]</isvisible> </pbox>
Table 4.168. Parameters of the pbox tag
Name | Type | Default | Description |
---|---|---|---|
pbox | Structure | Definition of a place in the portal page where a portlet may be rendered. | |
pbox.id | String | (required) | Id of the pbox. Must be unique within all pnodes and pboxes of the portal page. |
moduleid | String | NULL | Id of a portlet that shall be initially loaded into this pbox. |
isvisible | Boolean or PRule | true | Whether the pbox shall be visible or not. |
windowstate | String | normal | Initial windowstate in which the pbox shall be rendered. |
Portlet templates are specified in the Gentics Portlet Descriptor in the <templates> section of a specific portlet or may be overridden in the <pnode> tag in the Portal Template. The loading order is as follows. The first matching is taken.
PNode Template. See Section 11.1.3, “PNodes”
Portlet Template. See Section 4.4, “Gentics Portletdescriptor”
Portal Template. See Section 8.7, “template-section”
Plugin templates are specified in the Gentics Portlet Descriptor in the <templates> section of a specific plugin or may be overridden in the <pnode> tag in the Portal Template. The loading order is as follows. The first matching is taken.
PNode Template. See Section 11.1.3, “PNodes”
Portlet Template. See Section 4.4, “Gentics Portletdescriptor”
Plugin Template. See Section 4.4, “Gentics Portletdescriptor”
Portal Template. See Section 8.7, “template-section”
Velocity is a simple but powerful template language which is part of the Apache Jakarta Project. For full documentation see: http://velocity.apache.org/.
VTL (Velocity Template Language) has a few predefined language constructs - the most important are listed here:
Comments
Single line comments using two hashes: ## This is a comment
Multiline comments using #* this is a comment *#
References - Indicated using a $ - e.g. $myvar
There are three types of References in the VTL: variables, properties and methods. Variables are objects which are in the Velocity Context, e.g. using #set( $myvar = "test" ) would set the Variable $myvar
Properties look like: $myobj.myproperty - Velocity will first try to call the java method .get( "myproperty" ) on the specified object, if it is not found it will try to call .getMyproperty().
Methods can simply be called using $myobj.myMethod() which would call the method specified and returns the object of the method.
Directives and Velocimacros
To call predefined VTL Directives simply use a hash followed by it's name. e.g.: #set( $var = "value" ), #if( $var == "$value" ) #else #end, #foreach( $var IN $collection ) #end, etc.
Velocimacros are userdefined directives which look very similar in it's syntax but are defined in a VTL file using: #macro( macroName $argName1 $argName2 ) #end - they are then called using #macroName( $argValue1 $argValue2 )
![]() | Note |
---|---|
The Velocity Template Language is very powerful and most is far beyond the scope of this short Introduction. So if you have never used Velocity before you should head over to the Velocity User Guide to get more in-depth documentation. |
The templateengine's context contains usefull objects, which can be addressed through Section 8, “Portal Property Paths” .
$portal - the portal object, including imps and i18n.
$javax.portlet - portlet information, including context, config, request and response.
$portlet - the portlet rendering the template (may be null if the template is not rendered by a portlet)
$plugin - the plugin rendering the template (may be null if the template is not rendered by a plugin)
$position - the current position of the portlet (may be null if the template is not rendered by a portlet)
$ctx - the velocity context