Skip to content

Instantly share code, notes, and snippets.

@natecavanaugh
Created January 10, 2012 21:08
Show Gist options
  • Save natecavanaugh/1591216 to your computer and use it in GitHub Desktop.
Save natecavanaugh/1591216 to your computer and use it in GitHub Desktop.
Liferay - set custom css class from theme
//replace LINK_ID
//Add this to your theme vm
<div id="LINK_ID">
<a href="javascript:;" data-customCssClass="red">Red</a>
<a href="javascript:;" data-customCssClass="blue">Blue</a>
<a href="javascript:;" data-customCssClass="green">Green</a>
</div>
//Add this to your JS somewhere
A.one('#LINK_ID').delegate(
'click',
function(event){
var cssClass = event.currentTarget.attr('data-customCssClass');
if (cssClass) {
A.io.request(
themeDisplay.getPathMain() + '/portal/session_click',
{
data: {
'theme_custom_css_class': cssClass
}
}
);
}
},
'a'
);
// Add this to custom.vm
#set ($theme_custom_css_class = $getterUtil.getString($sessionClicks.get($request, "theme_custom_css_class", "")))
#if ($panelsMinimized != "")
#set ($css_class = "${css_class} $theme_custom_css_class")
#end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment