RE: Portlet Decorator not working

thumbnail
Hamidul Islam, modified 6 Years ago. Regular Member Posts: 111 Join Date: 5/22/08 Recent Posts

Hi All,

I have embedded search portlet in my custom theme. I am trying to apply my custom CSS class to the embedded search portlet. However, the CSS class is not getting applied to the portlet. Here are the steps I have followed 

1. Define the portlet decorator:

In the liferay -look-and-feel.xml file, I have mentioned the below 

&nbsp;&lt;portlet-decorator id=" bnpsearch " name=" bnpsearch "&gt;<br> &nbsp; &nbsp; &nbsp; &nbsp; &lt;portlet-decorator-css-class&gt;portlet-bnp-search&lt;/portlet-decorator-css-class&gt;<br> &nbsp;&lt;/portlet-decorator&gt;

2. Define the CSS class .portlet- bnp -search : 

I have defined CSS class in _portlet_decorator. scss file and imported in _custom. scss as below 

@import "corporate-templates/decorator/_portlet_decorator.scss";

3. Apply the decorator:  

I have applied the decorator to the embedded search portlet as follows 

&lt;#assign preferences = freeMarkerPortletPreferences.getPreferences("portletSetupPortletDecoratorId", " bnpsearch ") /&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br> &lt;@liferay.search default_preferences="${preferences}" /&gt;

 

After deploying the theme I should see the CSS class .portlet- bnp -search as a wrapper for the search portlet. But it's not happening. Is there anything that I am missing in the above steps? Can anyone please help me. 

 

Regards 

Hamidul Islam 

Rayappa Hattarwat, modified 6 Years ago. Junior Member Posts: 89 Join Date: 8/11/15 Recent Posts

Hi 

I think assgin like this working in theme

<#assign VOID = freeMarkerPortletPreferences.setValue("portletSetupPortletDecoratorId", "borderless") />

 

Regards,

Rayappa


 

thumbnail
Andrew Jardine, modified 6 Years ago. Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts

I would also add that I have sometimes found that you need to clear any existing preferences for your new ones to take effect. So let's say you have embedded the portlet in your theme and then loaded a page. The portlet preferences (the defaults) will now be saved in the PortletPreferences table so subsequent changes won't necessarily take effect. One sure fire way to make sure your changes DO take effect is to delete all the PortletPreference records that are specific to teh Search portlet. That will essentially clear it from all the layouts and since you are embedding the portlet, the (new) preferences will automatically be saved the next time you go to a page in your theme. 

 

You can delete the records directly from the table -- though this is never advised. If you do a direct "DELETE FROM .." statement, then you should probably restart your server to make sure all the caches and such are expired/cleared. A better option though would be to script something in the Control Panel > Server Adminsitration > Script tab that uses the API to do the same thing. Going through the API also means you shouldn't have to restart the server since the API route will automagically clear/expire caches for you.