Wednesday, 13 July 2011

Web Content Management and Liferay Variables

WEB CONTENT MANAGEMENT

Liferay’s Web Content Management (WCM) is a system which allows non-technical users to publish content to the Web without having advanced knowledge of Web technology or programming of any sort. Liferay Content Management System (CMS) empowers you to publish your content with a simple point-and-click interface, and it helps you to keep your site fresh.

You can use WCM to author both structured and unstructured content. Unstructured content is authored using an HTML-based WYSIWYG editor. Structured content is authored and displayed by combining Web Content Structures, Web Content Templates, and Web Contents. Structures and Templates are defined individually using a text editor or through the Liferay WCM UI.

Accessing Structure Elements

The following table shows how to access structure data from your Web Content Template code (when using Velocity templates; other template languages such as FreeMarker, XSL, or CSS have similar constructs). The variable name defined in the structure are denoted in bold and will be different depending on the name assigned in the structure.

Element Type
Velocity Template Accessors




Text Field
$tf.name,  $tf.data,  $tf.type






Text Box
$textbox.data






Text Area (HTML)
$textarea.data






Checkbox
$checkbox.data






Selectbox
$selectbox.data






Multi-Selection List
#foreach($selection  in  $mylist.options)




$selection


#end




Image Gallery
<img  src=”/image/image_gallery?img_id=$img.getData()”/>






Link to Page
$linkToPage.url






Repeatable
$el.siblings






Hierarchy
#foreach($child  in  $el.children)




$child.data


#end




Reserved Variables
$reserved-article-[id,version,title,create-date,modified-




date,  display-date,author-id,author-name,author-email-


address,author-comments,author-organization,author-


location,author-job-title].data





Template and Theme Variables

The following table lists the most common built-in variables accessible from Velocity Template code (when using Velocity templates; other template languages such as FreeMarker, CSS, or XSL have similar constructs). For example, $layout.getChildren(). Items marked with an asterisk (*) are only available from Liferay Theme files.

Variable Name
Description


request
HTTPServletRequest object


company
The current company object. This represents the portal instance on

which the user is currently navigating.


companyId
The current company ID.


groupId
ID of the group in which this web content is published.


locale
The current user's locale, as defined by Java.


randomNamespace
A randomized string.  It is very useful for creating IDs that are

guaranteed to be unique.


browserSniffer
Dynamic browser capabilities.  e.g.$browserSniffer.isMobile()


portal
Current portal instance


portletURLFactory
Creates portlet URLs (action URLs, etc)


stringUtil
Useful string utilities


portletConfig*
Standard PortletConfig object  describing information from the

portal.xml file.


renderRequest*
Standard Portlet RenderRequest object


renderResponse*
Standard Portlet RenderResponse object


themeDisplay*
Contains many useful items, such as the logged in user, the layout,

logo information, paths, and much more.


user*
The User object representing the current user.


layoutSet*
The set of pages to which the user has currently navigated. Generally,

communities and organizations have two: a public set and a private set.


scopeGroupId*
groupId that is used to identify the scope where the data of the

current portlet is stored and retrieved.  The scope can represent a

community, organization, user, the global scope, or a scope tied to a

specific page.


timeZone*
The current user's time zone, as defined by Java.


viewMode
e.g. “print” when clicked print icon


fullTemplatesPath*
Path to all templates used.


pageTitle*
Title of the page




serviceLocator
Access to other Liferay services.  Note by default this variable is

disabled, must be enabled via portal-ext.properties




prefsPropsUtil
Access to portal settings that were set from the Control Panel or

through the portal.properties configuration file.




permissionChecker
An object which can determine given a particular resource whether or

not the current user has a particular permission for that resource.


[css|images|javascrip
Full path to various theme files
t|templates]_folder*



LIFERAY ADMINISTRATION

Portal Properties

Liferay uses the concept of overriding the defaults in a separate file, rather than going in and customizing the default configuration file. The default configuration file is called portal. properties, and it resides inside of the portal-impl.jar file.
This .jar file is located in Liferay Portal’s WEB-INF/lib folder. If you have a copy of the Liferay source code, this file can be found in portal-impl/src. The file which is used to override the configuration is portal-ext.properties. This file can be created in your Liferay Home folder or anywhere in the application server’s classpath.

Database Setup

Out of the box, Liferay bundles are configured to use HSQLDB, which should only be used for development or demo purposes. You cannot use this database in production.

For production use, Liferay supports the following databases: MySQL, Microsoft SQL Server, Oracle Database, IBM DB2, PostgresSQL, and Sybase. Liferay can also connect to Apache Derby, Firebird, Informix, Ingres, or SAP DB. To use these databases, the database and user with appropriate access must be created, and the appropriate JDBC driver must

be available in your app server. Consult your database documentation for details on syntax and how to create databases and users.
To use a particular database, you must set the following four

properties in your portal-ext.properties.

MySQL Example:

1.
jdbc.default.driverClassName=com.mysql.jdbc.Driver
2.
jdbc.default.url=jdbc:mysql://localhost/lportal?

useUnicode=true&characterEncoding=UTF-

8&useFastDateParsing=false
3.
jdbc.default.username=
4.
jdbc.default.password=



Oracle Example:

jdbc.default.driverClassName=oracle.jdbc.driver.OracleDriver jdbc.default.url=jdbc:oracle:thin:@localhost:1521:xe jdbc.default.username=lportal

jdbc.default.password=lportal

It’s also possible to delegate this configuration to the application server through a DataSource by using the following property:

jdbc.default.jndi.name=NameOfDataSource

App Server Configuration

Liferay is supported on the following app servers or servlet containers: Geronimo, GlassFish, JBoss, Jetty, JOnAS, Oracle, Resin, Tomcat, WebLogic, and WebSphere. Consult your app server documentation for details on configuration. The following table lists common files that are involved in configuring your app server.

Tomcat 6.x
Location




Global Libraries
${TOMCAT_DIR}/lib/ext






Portal Libraries
${TOMCAT_DIR}/webapps/ROOT/WEB-INF/lib






Primary Configuration
${TOMCAT_DIR}/conf/server.xml






Primary Log Files
${TOMCAT_DIR}/logs/catalina.out






GlassFish 3.x
Location




Default Domain Directory
${GLASSFISH_DIR}/domains/domain1






Global Libraries
${GLASSFISH_DOMAIN_DIR}/lib






Portal Libraries
${GLASSFISH_DOMAIN_DIR}/applications/j2ee-modules/




Liferay-portal/WEB-INF/lib




Primary Configuration
${GLASSFISH_DOMAIN_DIR}/config/domain.xml






Primary Log Files
${GLASSFISH_DOMAIN_DIR}/logs/server.log






JBoss 5.x
Location




Default Instance Directory
${JBOSS_DIR}/server/default






Global Libraries
${JBOSS_INSTANCE_DIR}/lib






Portal Libraries
${JBOSS_INSTANCE_DIR}/deploy/ROOT.war/WEB-INF/lib






Primary Configuration
${JBOSS_INSTANCE_DIR}/conf/jboss-service.xml






Primary Log Files
${JBOSS_INSTANCE_DIR}/log/server.log  ${JBOSS_INSTANCE_




DIR}/log/boot.log





Troubleshooting and Debugging

The following items should be checked when troubleshooting a problem.

Item
Notes


Log Files
Log files for several app servers are listed above. These should be checked for

warnings, errors, Java stack traces, etc.


Log Settings
Liferay uses the Apache Log4j library to perform all of its logging operations.

See below on how to configure log settings.


JMX
Liferay provides out-of-the-box JMX MBeans, which allow introspection into

the runtime, for example to identify and isolate problematic behavior such as

poor cache performance or slow portlet rendering.


Debug
To attach a Java debugger to Liferay, you must start the JVM with special

properties. Some servers have done this for you. For example, to start Tomcat

under a debugger, run “bin/catalina.sh jpda start”

Other servers may need the JVM properties added manually. A typical set of

properties is:

-Xdebug

-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005


3 comments:

  1. his is so interesting blog. You are best listing knowledge provide at this site. I am very excited read this nice article. web content management Thank you for the info.

    ReplyDelete
  2. you have a great listing knowledge your article is really helpful and full of information and knowledge. thanks for sharing it with us.
    www.digitalsence.com

    ReplyDelete