Using Developer Mode with Themes

Do you want to develop Liferay Portal themes without having to redeploy to see your modifications? Use Liferay Portal’s Developer Mode! In Developer Mode, all caches are removed, so any changes you make are visible right away. Also, you don’t have to reboot the server as often in Developer Mode.

How does Developer Mode let you see your changes more quickly? By default, Liferay Portal is optimized for performance. Developer mode optimizes your configuration for development instead. Here is a list of Developer Mode’s key behavior changes and the Portal Property override settings that trigger them (if applicable):

  • CSS files are loaded individually rather than being combined and loaded as a single CSS file (theme.css.fast.load=false).
  • Layout template caching is disabled (layout.template.cache.enabled=false).
  • The server does not launch a browser when starting (browser.launcher.url=).
  • FreeMarker Templates for themes and web content are not cached, so changes are applied immediately (via the system setting in your Liferay Portal instance).
  • Minification of CSS and JavaScript resources is disabled (minifier.enabled=false).

Individual file loading of your styling and behaviors, combined with disabled caching for layout and FreeMarker templates, lets you see your changes more quickly.

These developer settings are defined in the portal-developer.properties file. To use these settings, you can include them in your portal-ext.properties file or copy them over to your portal-ext.properties file and override specific properties as needed. These configurations are covered in this tutorial.

First, you can explore how it’s done in IDE.

Setting Developer Mode for Your Server in IDE

To enable Developer Mode for your server in IDE, follow these steps:

  1. Double-click on your server in the Servers window and open the Liferay Launch section.

  2. Select Custom Launch Settings and check the Use developer mode option.

  3. Save the changes and start your server.

developer-mode-ide.png

Figure 1: The Use developer mode option lets you enable Developer Mode for your server in IDE.

For Liferay Portal servers below version 6.2 (e.g., Liferay v6.1 CE Server, Liferay v6.0 CE Server), IDE enables Developer Mode by default. When starting your Liferay Portal server for the first time, it creates a portal-ext.properties file in your server’s directory. This properties file contains the property setting include-and-override=portal-developer.properties, which enables Developer Mode.

Most of the configuration is provided by the portal-developer.properties file, but you still have to configure the FreeMarker template setting. Follow the steps in the Configuring FreeMarker System Settings section to configure the FreeMarker template cache.

If you’re not using IDE, manual configuration for Developer Mode is covered next.

Setting Developer Mode for Your Server Using portal-developer.properties

To set Developer Mode manually, you must point to portal-developer.properties as shown in the last section. Add the portal-ext.properties file to the root folder of your app server’s bundle and add the following line:

include-and-override=portal-developer.properties

Developer Mode is enabled upon starting your app server. portal-developer.properties provides the majority of the settings you’ll need for smooth development. To disable the cache for FreeMarker templates, you must update the System Setting covered in the next section.

Configuring FreeMarker System Settings

FreeMarker Templates for themes and web content are cached by default. Therefore, any changes you make to your FreeMarker theme templates aren’t immediately displayed. You can change this behavior through System Settings. Follow these steps:

  1. Open the Control Panel and go to ConfigurationSystem Settings.

  2. Click the Foundation tab and select FreeMarker Engine.

  3. By default, the Resource modification check (the time in milliseconds that the template is cached) is set to 60. Set this value to 0 to disable caching.

Your FreeMarker templates are ready for development. Next you can learn how you can improve JavaScript file loading for development.

JavaScript Fast Loading

By default, JavaScript fast loading is enabled in Developer Mode (javascript.fast.load=true). This loads the packed version of files listed in the Portal Properties javascript.barebone.files or javascript.everything.files. You can, however, disable JavaScript fast loading for easier debugging for development. Just set javascript.fast.load to false in your portal.properties, or you can disable fast loading by setting the URL parameter js_fast_load to 0.

Great! You’ve set up your Liferay Portal server for Developer Mode. Now, when you modify your theme’s file directly in your bundle, you can see your changes applied immediately on redeploying your theme!

Related Topics

Creating Layout Templates Manually

Creating Themes with IDE

0 (0 Votes)
Importing Resources with a Theme Previous