Good middle-tier java developers will never understand the confusion and frustration that UI designers feel when faced with a challenge like Liferay. It’s difficult enough to design well for the web, but when you throw in a platform with such extensive capabilities – capabilities that remove the crutches offered by static content – it really approaches impossibility.
Nothing is fixed. And that statement can mean a lot of things to a Liferay theme designer with a pressing deadline.
So take a challenge like switching themes dynamically. Can it be done? Well, sure. Any good middle-tier developer will write you a few overloaded methods, re-deploy portal-impl.jar, copy and paste you the API, and have you on your way. But, what if you don’t have a good middle-tier developer with time to help at your disposal? Can it be done then? Sure it can. And here’s how:
#set ($themeServeletContext = $themeServletContext.getContext("/sevencogs-theme")) $request.setAttribute("CTX",$themeServletContext) $themeDisplay.getTheme().setServletContextName("sevencogs-theme") $themeDisplay.getTheme().setLookAndFeel($themeServletContext.getContextPath(), $themeDisplay.getTheme(), "") $themeDisplay.getTheme().setTemplatesPath("/templates") $themeDisplay.getTheme().setCssPath("/css") $themeDisplay.getTheme().setImagesPath("/images") $themeDisplay.getTheme().setJavaScriptPath("/images") <script> window.onload=function() { window.location=window.location.href; } </script> ## Download vanilla Liferay 5.2.3 ## Rename liferay-portal-5.2.3tomcat-6.0.18webappsROOTWEB-INFclassesportal-developer.properties ## to portal-ext.properties ## Edit liferay-portal-5.2.3tomcat-6.0.18confcontext.xml.## Edit liferay-portal-5.2.3tomcat-6.0.18webappsROOThtmlthemesclassictemplatesportal_normal.vm ## Copy and paste this block to portal_normal.vm ## Start your tomcat ## When the server has started, point your browser to http://localhost:8080/web/guest/ ## Voila, sevencogs-theme running where it should be classic. Note $themeDisplay.getTheme().getThemeId() /proxy-theme/portal_normal.vm

