Showing posts with label Theme. Show all posts
Showing posts with label Theme. Show all posts

Monday, 22 September 2014

Liferay 6.1, resolving SASS: Invalid CSS Error

I found this error when using Bootstrap in my Liferay 6.1 CE theme. Every time a page loads with the theme, a huge error log was created with SASS Exception. This is the solution that worked for me.

1. Download the below file and Replace the file in liferay-portal-6.1.1-ce-ga2\tomcat-7.0.27\webapps\ROOT\WEB-INF\lib folder.
ruby-gems.jar

2. Add the following lines to your portal-ext.properties file
scripting.jruby.load.paths=\
  classpath:/META-INF/jruby.home/lib/ruby/site_ruby/1.8,\
  classpath:/META-INF/jruby.home/lib/ruby/site_ruby/shared,\
  classpath:/gems/chunky_png-1.2.6/lib,\
  classpath:/gems/compass-0.12.2/lib,\
  classpath:/gems/fssm-0.2.9/lib,\
  classpath:/gems/sass-3.2.1/lib,\
  ${java.io.tmpdir}/liferay/ruby/gems/chunky_png-1.2.6/lib,\
  ${java.io.tmpdir}/liferay/ruby/gems/compass-0.12.2/lib,\
  ${java.io.tmpdir}/liferay/ruby/gems/fssm-0.2.9/lib,\
  ${java.io.tmpdir}/liferay/ruby/gems/sass-3.2.1/lib

Restart the server and all SASS errors will have disappeared.
If it still hasn't gone, you might have to stop Liferay, clean the liferay-portal-6.1.1-ce-ga2\tomcat-7.0.27\temp, liferay-portal-6.1.1-ce-ga2\tomcat-7.0.27\work and C:\Users\{YOUR.USER.NAME}\AppData\Local\Temp directories and Start the Liferay server.

Credits go to Kan Zhang for the info. Link to Original Post below:
Resolve the "Sass::SyntaxError: Invalid CSS" error in Liferay 6.1

Wednesday, 17 September 2014

Liferay, Display Docbar based on User Role

Firstly go to Control Panel > Roles and create a Role Dockbar. This is the Name that will be used to check if the Dockbar has to be displayed to the User.

In the portal_normal.vm file, present in the theme, we have to modify the below lines. Right now, dockbar is visible to anybody who signs in. We need to change it so that it is visible to users with a specific role.
#if ($is_signed_in)
 #dockbar()
#end
This makes the com.liferay.portal.service.UserService available in the Velocity Template. It is assigned to the $userService variable.
#set($userService = $serviceLocator.findService("com.liferay.portal.service.UserService"))
This line Calls the hasRoleUser method, to check if the user has the Role Dockbar assigned to him.
#set($docbarVisible = $userService.hasRoleUser($company_id, "Dockbar", $user_id, true))
The below line checks if the user is Signed In AND has the role Dockbar OR if the User is the Company Admin.
#if ($is_signed_in && ($docbarVisible || $permissionChecker.isCompanyAdmin()))
Final Code
#set($userService = $serviceLocator.findService("com.liferay.portal.service.UserService"))
#set($docbarVisible = $userService.hasRoleUser($company_id, "Dockbar", $user_id, true))

#if ($is_signed_in && ($docbarVisible || $permissionChecker.isCompanyAdmin()))
 #dockbar()
#end
Now all that is left out is to assign few users the Dockbar role to verify that the Users will have access to the Dockbar. Hope the entire thing makes sense.
Feel free to post your comments.