« Zurück zu Using Liferay

Change Liferay Default Theme

This page needs updating.. For more information, see Wiki - Need Updating.

Introduction #

Whenever a new community website (layout set) or a user homepage is created a default theme is applied. Liferay comes configured to use one of its themes, 'classic', as the default. But you can change this behaviour and set the default theme to one of your own.

This article also explains how to configure Liferay to prevent users to change the theme to other different than the default.

WARNING #

If you do change the theme in the portal.properties or in the portal.ext.properties, and then forget to deploy the theme, you won't be able to log in to Liferay.

Quick and Easy #

  1. Open the liferay-look-and-feel.xml that contains the theme you want as your default.###
    1. Find the theme id. Example: <theme id="mynewtheme" name="New Theme"> The theme id is mynewtheme.
  2. Open portal-ext.properties or create it if it does not exist and put it next to portal.properties. If you are using the ext development environment edit \ext-ejb\classes\portal-ext.properties###
    1. Paste this line of code into the file: default.theme.id=
    2. Place the theme id after the above code. Example: default.theme.id=mynewtheme

Note: As of 6.x, you cannot just use the theme id specified in the liferay-look-and-feel.xml. Instead, go to Control Panel->Plugins Configuration->Click on theme of interest->note the Plugin ID and use that

In Depth Look #

A default theme comes into play when you create a new community. There are 3 files you need to know about when it comes to setting the default theme for Liferay:

  • portal.properties
  • liferay-look-and-feel.xml
  • portal-ext.properties

portal.properties #

:Locate "Look and Feel" in ..\portal-ejb\classes\portal.properties :Take notice of this line: default.theme.id=classic :By default, the classic theme is used as the default theme.

 ##
 ## Look and Feel
 ##
    #
    # Set the following to false if the system does not use allow users to
    # modify the look and feel.
    #
    look.and.feel.modifiable=true
    #
    # Set the default theme id.
    #
    default.theme.id=classic
    #
    # Set the default color scheme id.
    #
    default.color.scheme.id=01

portal.properties [4.3.X+] #

:Locate "Look and Feel" in ..\portal-impl\classes\portal.properties :Take notice of this line: default.regular.theme.id=classic :By default, the classic theme is used as the default theme.

 ##
 ## Look and Feel
 ##
    #
    # Set the following to false if the system does not use allow users to
    # modify the look and feel.
    #
    look.and.feel.modifiable=true
    #
    # Set the default theme id for regular themes.
    #
    default.regular.theme.id=classic
    #
    # Set the default color scheme id for regular themes.
    #
    default.regular.color.scheme.id=01
    #
    # Set the default theme id for wap themes.
    #
    default.wap.theme.id=mobile
    #
    # Set the default color scheme id for wap themes.
    #
    default.wap.color.scheme.id=01
    #
    # Set the following to true if you want a change in the theme selection of
    # the public or private group to automatically be applied to the other (i.e.
    # if public and private group themes should always be the same).
    #
    theme.sync.on.group=false

liferay-look-and-feel.xml #

:All themes used in Liferay it will have a liferay-look-and-feel.xml that defines it. :Locate the liferay-look-and-feel.xml file that corresponds to the theme you want to be default. :Look for a line that looks similar to: <theme id="aqua" name="Aqua">. Notice this particular theme id is called aqua. Note: In version 5.0.1 there is another property to change:<root-path>/html/themes/classic</root-path>. The value of this property should be the location of the default theme, you should change it accordingly. For example:<root-path>/html/themes/myTheme</root-path>.

portal-ext.properties #

:Instead of editing portal.properties directly it's best practice edit/copy the necessary code you want to overwrite into portal-ext.properties file in \ext-ejb\classes\portal-ext.properties. :Copy default.theme.id=classic (portal.properties) to your portal-ext.properties file and edit it to point to the theme id of the theme you want to set as your default. :Please note that in Liferay 4.3 you will need to copy a slightly different code into your portal.ext.properties file: default.regular.theme.id=classic.

Congratulations, you've just changed the Liferay default theme!

0 Anhänge
96426 Angesehen
Durchschnitt (6 Stimmen)
Die durchschnittliche Bewertung ist 2.5 von max. 5 Sternen.
Kommentare
Antworten im Thread Autor Datum
In 5.2.2, following point 4.1 and setting the... Peter Oxenham 30. März 2009 23:17
Thanks peter, it's working but seems that in my... Chris Tophe 12. Januar 2010 00:41
Unable to get this to work. Has anyone else had... Scott Palmer 13. Oktober 2010 22:45
Managed to get this working. The instructions... Scott Palmer 14. Oktober 2010 01:46
I am using Liferay 6.0.4, and I am not able to... Kiran Kumar 18. Oktober 2010 19:42
For those still searching for the right value... Ray Parker 29. Oktober 2010 05:40

In 5.2.2, following point 4.1 and setting the default theme to the theme's id will cause some problems. LEP-6725 has some more detail.

It seems the correct way is to use the 'JsSafePortletId' version of the ID.

So if mynewtheme is deployed in a war call mytheme.war, the default theme id would be set like

default.regular.theme.id=mytheme_WAR_mynewtheme
Gepostet am 30.03.09 23:17.
Thanks peter, it's working but seems that in my case it would be mynewtheme_WAR_mytheme . wierd ...
Gepostet am 12.01.10 00:41 als Antwort auf Peter Oxenham.
Unable to get this to work. Has anyone else had any luck. Have tried the method in the guide above and Peter's method. Both fail at startup with the "no theme with id xxxxx can be found"
Gepostet am 13.10.10 22:45 als Antwort auf Peter Oxenham.
Managed to get this working.

The instructions in Liferay's guide only apply if you have your theme under the Liferay ROOT (/html/themes/THEMENAME). If you are deploying your theme from a .war file then you are probably not going to fall into this category. Note the following applies to tomcat 6 so if your using something else you may need to improvise.

So if you are deploying your theme outside of Liferay's context. You can get it to work by doing the following:

1) Check your /webapps/ directory and note the name of the theme folder (Say /webapps/example-theme/)
2) Check your /webapps/THEME/WEB-INF/liferay-look-and-feel.xml to find the theme ID (<theme id="example" name="Name">)
3) The theme ID you will need to put into your portal-ext.properties is "example_WAR_exampletheme"

The format is theme-id_WAR_context (hypens removed if your theme is multiple words - context is the folder name of your theme in the /webapps/ directory)

Hope that helps a few people and thanks to Peter for pointing us in the right direction.
Gepostet am 14.10.10 01:46 als Antwort auf Scott P.
I am using Liferay 6.0.4, and I am not able to get this working. The default theme is not getting set to the one I specified in the portal-ext.properties. But the theme is getting installed in Liferay.

Appreciate any help in this regard.
Gepostet am 18.10.10 19:42 als Antwort auf Scott P.
For those still searching for the right value for this, and especially if you don't have an easy means of peeking around in the Liferay database, I found a simple means to get the correct value. Export a community which uses the theme in question. After the LAR file is downloaded, open it using your favorite archive tool, and look at the manifest.xml file in the root. The name of the theme associated with the community will be found on the <header> tag under the theme-id attribute. The theme name will be provided whether you have included the actual theme in the export or not.
Gepostet am 29.10.10 05:40.