Display Custom Field on Nav_item

$nav_item.getLayout().getExpandoBridge().getAttribute(“custom_field_attribute_name”)

Logout and stay within current community

This code logs you out and then reloads the current community instead of sending you to the guest community.

Add Localization in a Theme by Ray Augé

to add localizations in a theme, add this compile section your your build.xml and the languages in the usual location
- this can be useful if you add your own custom settings that the keys are not in the portal’s language.properties file.

(Source: liferay.com)

Velocity #foreach Variables

I came across some velocity variables (1.6.4) that could help you save a couple lines of code.

$velocityCount: Current index of the foreach loop (starts at 1)
$velocityHasNext: Checks if there is another item in the loop

-Freemarker version

(Source: velocity.apache.org)

Mobile Web Testing

This week I have been exploring the world of mobile web. One issue I ran into was not being able to see what css classes exsist while viewing Liferay from an iPhone or Android phone. Here is a simple javascript link that can be added in your portal_normal.vm file.

While in a mobile browser you can click the link to see what css classes you can use to target your mobile experience

Liferay 6.1 Compass and Sass

to use these features in Liferay 6.1 just add

@import “compass”;

at the top of your custom.css file in your theme.

Resources: SaSS and Compass


here are some things I like about it:

COMPASS:
@include border-radius(4px);
OUTPUTTED CSS:
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
-o-border-radius: 4px;
-ms-border-radius: 4px;
-khtml-border-radius: 4px;
border-radius: 4px;

SASS lets you set variables and use them throughout your code:
$dark-blue: #2C4762;
$mobile-view-width: 300px;
$default-margin: 20px;
$calc-width: $mobile-view-width - $default-margin;

Tips for Liferay Layouts

1. Use Table Based Layouts for Browsers IE 6 & 7 (#if ($browserSniffer.isIe($request) && $browserSniffer.getMajorVersion($request) )

2. Set “main-content” class to be the layout name. That way you can target via CSS when this layout is in use.

3. Remember Layouts can be embedded in a theme or deployed to the entire Liferay Server.