We used cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it. What For?

Liferay 6.1 Responsive Theme

Nowadays, People surf your website on a various devices as mobile/tablet has become a significant part of our daily life. Responsive design makes website adaptive across at various devices.

 

Since Liferay 6.1 does not provide responsiveness functionality by default, we have to achieve this manually. I prefer Bootstrap 2.3.2 library to achieve this functionality as Liferay 6.2 uses it.

 

Basic requirements are as follow to start the theme development.

 

Basic Requirements :

  • Liferay 6.1 CE/EE

  • Liferay 6.1 plugin sdk

  • Twitter Bootstrap 2.3.2 library

 

Download Twitter Bootstrap 2.3.2 library from following link.

 

http://getbootstrap.com/2.3.2/assets/bootstrap.zip

 

We required following things from downloaded bundle.

 

Minified version:

 

CSS

  • bootstrap.min.css

  • bootstrap-responsive.min.css

JS

  • bootstrap.min.js

 

Theme creation:

 

Here, I am creating a sample responsive theme.

 

  1. Open IDE(Eclipse/Liferay Developer Studio). Go to File -> New -> Liferay Plugin Project.

Make the following selections:

  • Build type: Ant/Maven

  • Plugins SDK: [a configured Plugins SDK]

  • Liferay runtime: [a configured Liferay runtime]

  • Plugin Type: Theme

Select Next

-->  Choose parent theme (_styled / _unstyled / classic). As for now select classic as a parent theme.

--> Choose Theme Framework (Freemarker / Velocity / jsp).

--> Click on Finish.

Theme directory structure:

  • Liferay-Responsive-theme/

    • docroot

    • WEB-INF

    • _diffs/ - subfolders not created by default.

      • css

      • images

      • js

      • templates

    • css

    • images

    • js

    • templates

  1. The _diffs folder must mirror the parent theme’s directory structure.

  2. Add bootstrap.min.js under _diffs --> js directory.

  3. Add bootstrap.min.css and bootstrap-responsive.min.css under _diffs --> css directory.

  4. Add your custom css under  _diffs --> css directory for as per the requirements.

  5. Copy main.css from Liferay-Responsive-theme --> css directory and paste in Liferay-Responsive-theme --> _diffs --> css.

  6. Now Import bootstrap and custom css in main.css as follows.

 

main.css

 

@import url(base.css);

@import url(application.css);

@import url(layout.css);

@import url(dockbar.css);

@import url(navigation.css);

@import url(portlet.css);

@import url(forms.css);

@import url(extras.css);

@import url(custom.css);

 

/* *** Bootstrap css *** */

@import url(bootstrap.min.css);

@import url(bootstrap-responsive.min.css);

 

/* *** custom css *** */

@import url(theme.css);

 

/* *** custom responsive css *** */

@import url(responsive.css);

 

  1. Add following css in your custom css(theme.css).

 

#wrapper{min-width:90%;max-width:90%;}

 

Note : Change value accordingly your requirements.

 

  1. Deploy theme using command ant clean deploy.

 

Responsive layout (optional):

 

  • Example : 1-2-1(100% | 50%-50% | 100%) columns responsive layout.

 

  1. Responsive-1-2-1-columns-layout.tpl file would be as follow.

 

<div class="columns-1-2-1" id="main-content" role="main">

      <div class="portlet-layout row-fluid">

<div class="portlet-column portlet-column-only span12" id="column-1">

$processor.processColumn("column-1", "portlet-column-content portlet-column-content-only")

</div>

      </div>

      <div class="portlet-layout row-fluid">

<div class="portlet-column portlet-column-first span6" id="column-2">

$processor.processColumn("column-2", "portlet-column-content portlet-column-content-first")

</div>

<div class="portlet-column portlet-column-last span6" id="column-3">

$processor.processColumn("column-3", "portlet-column-content portlet-column-content-last")

</div>

      </div>

      <div class="portlet-layout row-fluid">

<div class="portlet-column portlet-column-only span12" id="column-1">

$processor.processColumn("column-1", "portlet-column-content portlet-column-content-only")

</div>

      </div>

          </div>

 

  1. Your theme will look like as shown in the following screenshots:

 

Desktop View :

desktop.png

 

Mobile View:

mobile.png

 

Download sample theme war from below link :

 

 
contact-us Request a callback WhatsApp