Message Boards
Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme
Sandip Patel, modified 7 Years ago.
Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme
Regular Member Posts: 205 Join Date: 1/5/11 Recent Posts
Hi,
I am using Liferay 7 EE GA1. I have requirement to embed asset publisher portlet in Liferay theme. I can achieve it by following code.
<@liferay_portlet["runtime"]
portletProviderAction=portletProviderAction.VIEW
portletProviderClassName="com.liferay.asset.kernel.model.AssetEntry"/>
Now I want to set preferences for this asset publisher like which are the type of asset needs to be display, disabled borders, display templates etc.
How Can I set portlet preference in Liferay 7 theme ???
Please note I am using Freemarker Template language in Liferay Theme.
I can not find proper documentation for same in Liferay site.
Any pointer/help will be appreciated.
Regards,
Sandip Patel
I am using Liferay 7 EE GA1. I have requirement to embed asset publisher portlet in Liferay theme. I can achieve it by following code.
<@liferay_portlet["runtime"]
portletProviderAction=portletProviderAction.VIEW
portletProviderClassName="com.liferay.asset.kernel.model.AssetEntry"/>
Now I want to set preferences for this asset publisher like which are the type of asset needs to be display, disabled borders, display templates etc.
How Can I set portlet preference in Liferay 7 theme ???
Please note I am using Freemarker Template language in Liferay Theme.
I can not find proper documentation for same in Liferay site.
Any pointer/help will be appreciated.
Regards,
Sandip Patel
pratik parekh, modified 7 Years ago.
RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme
New Member Posts: 18 Join Date: 9/9/14 Recent Posts
I am having same question.
I have found one solution where Liferay set portlet preference for Application Decorators.
You can check code snippets here
I have tried the same but getting error : unknown property 'default_preferences'.
following is stack trace :
If anyone have worked on similar functionality, please provide some inputs.
I have found one solution where Liferay set portlet preference for Application Decorators.
You can check code snippets here
I have tried the same but getting error : unknown property 'default_preferences'.
following is stack trace :
12:51:38,124 ERROR [http-nio-8080-exec-10][runtime:60] Error executing FreeMarker template
FreeMarker template error:
Unknown property "default_preferences" on instance of com.liferay.taglib.portletext.RuntimeTag
----
FTL stack trace ("~" means nesting-related):
- Failed at: @liferay_portlet["runtime"] portletPr... [in template "kms-theme_SERVLET_CONTEXT_/templates/portal_normal.ftl" at line 71, column 9]
----
Java stack trace (for programmers):
----
freemarker.template.TemplateModelException: [... Exception message was already printed; see it above ...]
at freemarker.ext.jsp.JspTagModelBase.setupTag(JspTagModelBase.java:101)
at freemarker.ext.jsp.TagTransformModel.getWriter(TagTransformModel.java:65)
at freemarker.core.Environment.visitAndTransform(Environment.java:412)
at freemarker.core.UnifiedCall.accept(UnifiedCall.java:107)
at freemarker.core.Environment.visit(Environment.java:324)
at freemarker.core.MixedContent.accept(MixedContent.java:54)
at freemarker.core.Environment.visit(Environment.java:324)
at freemarker.core.Environment.process(Environment.java:302)
at freemarker.template.Template.process(Template.java:325)
at com.liferay.portal.template.freemarker.FreeMarkerTemplate.processTemplate(FreeMarkerTemplate.java:121)
at com.liferay.portal.template.AbstractSingleResourceTemplate.processTemplate(AbstractSingleResourceTemplate.java:78)
at com.liferay.taglib.util.ThemeUtil.doIncludeFTL(ThemeUtil.java:283)
at com.liferay.taglib.util.ThemeUtil.doDispatch(ThemeUtil.java:157)
at com.liferay.taglib.util.ThemeUtil.includeFTL(ThemeUtil.java:100)
at com.liferay.taglib.util.ThemeUtil.include(ThemeUtil.java:82)
at com.liferay.taglib.theme.IncludeTag.doEndTag(IncludeTag.java:34)
at org.apache.jsp.html.common.themes.portal_jsp._jspx_meth_liferay_002dtheme_005finclude_005f1(portal_jsp.java:759)
at org.apache.jsp.html.common.themes.portal_jsp._jspService(portal_jsp.java:696)........
If anyone have worked on similar functionality, please provide some inputs.
Eduardo P. García, modified 3 Years ago.
RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme
Regular Member Posts: 157 Join Date: 3/16/12 Recent Posts
Hi guys,
You can use the freeMarkerPortletPreferences variable to set the portlet preferences when embedding a portlet with the runtime taglib. Do not forget to cleanup the variable using the .reset() method.
I hope this helps.
Regards
You can use the freeMarkerPortletPreferences variable to set the portlet preferences when embedding a portlet with the runtime taglib. Do not forget to cleanup the variable using the .reset() method.
<#assign VOID = freeMarkerPortletPreferences.setValue("displayStyle", "my_global_adt_key")>
<#assign VOID = freeMarkerPortletPreferences.setValue("displayStyleGroupId", themeDisplay.getCompanyGroupId()?string)>
<@liferay_portlet["runtime"]
defaultPreferences=freeMarkerPortletPreferences
portletProviderAction=portletProviderAction.VIEW
portletProviderClassName="com.liferay.asset.kernel.model.AssetEntry"
/>
<#assign VOID = freeMarkerPortletPreferences.reset()>
I hope this helps.
Regards
A G, modified 7 Years ago.
RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme
New Member Posts: 14 Join Date: 2/1/17 Recent Posts
Hello
I´m trying to use the code you provided for changing breadcrumbs display in this way:
Alternatively, I have tried with this code (and with the same freeMarkerPortletPreferences ):
Where 36706 is the template key for my ADT, which contains a new display for the breadcrumbs.
The problem is that the breadcrumbs still mantain their default display. It seems that the defaultPreferences are not taken into account.
Do yo know how to solve this ?
I have been many days around the problem but I can't find a solution.
Thank you in advance!!
I´m trying to use the code you provided for changing breadcrumbs display in this way:
<#assign VOID = freeMarkerPortletPreferences.setValue("displayStyle", "ddmTemplate_36706")>
<#assign VOID = freeMarkerPortletPreferences.setValue("displayStyleGroupId", themeDisplay.getCompanyGroupId()?string)>
<@liferay_portlet["runtime"]
defaultPreferences="${freeMarkerPortletPreferences}"
portletProviderAction=portletProviderAction.VIEW
portletProviderClassName="com.liferay.portal.kernel.servlet.taglib.ui.BreadcrumbEntry"
/>
Alternatively, I have tried with this code (and with the same freeMarkerPortletPreferences ):
<@liferay.breadcrumbs default_preferences="${freeMarkerPortletPreferences}" />
Where 36706 is the template key for my ADT, which contains a new display for the breadcrumbs.
The problem is that the breadcrumbs still mantain their default display. It seems that the defaultPreferences are not taken into account.
Do yo know how to solve this ?
I have been many days around the problem but I can't find a solution.
Thank you in advance!!
Jacopo Bartolini, modified 7 Years ago.
RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme
Junior Member Posts: 28 Join Date: 1/19/17 Recent PostsSandip Patel:
Now I want to set preferences for this asset publisher like which are the type of asset needs to be display, disabled borders, display templates etc.
Hi, I've got the same problem. I have a Web Content Display embedded in my theme, I've got several pages, and I would like to set different content for each portlet. Have you been able to solve this issue? How have you done it? Thanks in advance
A G, modified 7 Years ago.
RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme
New Member Posts: 14 Join Date: 2/1/17 Recent Posts
Hello. I´ve tried to solve it in many ways but I didn´t reach a solution yet.
I have no idea of what could be the problem, I´m lost
If I reach any conclusion, I will write it here.
Please, If you get it, let me know.
Thanks in advance
I have no idea of what could be the problem, I´m lost
If I reach any conclusion, I will write it here.
Please, If you get it, let me know.
Thanks in advance
Andrew Jardine, modified 6 Years ago.
RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme
Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
I'm currently experiencing the same issue with the search portlet. It's embedded in the theme of course, but this code doesn't seem to be working -- despite the fact that it is following the guide.
.. I checked the Liferay source and found --
.. which to me looks like I am doing it properly, but the result is the same. I also checked the portlet preferences table and can't find any preferences there which I assume confirms that the defaults I am providing are not being save. Would love to know what is not working.
<#assign VOID = freeMarkerPortletPreferences.setValue("searchScope", "everything") />
<@liferay.search default_preferences="${freeMarkerPortletPreferences}" />
<#assign VOID = freeMarkerPortletPreferences.reset() />
.. I checked the Liferay source and found --
<#macro search
default_preferences = ""
>
<#if is_setup_complete>
<@liferay_portlet["runtime"]
defaultPreferences=default_preferences
portletProviderAction=portletProviderAction.VIEW
portletProviderClassName="com.liferay.admin.kernel.util.PortalSearchApplicationType$Search"
/>
<!--#if-->
<!--#macro-->
.. which to me looks like I am doing it properly, but the result is the same. I also checked the portlet preferences table and can't find any preferences there which I assume confirms that the defaults I am providing are not being save. Would love to know what is not working.
Andrew Jardine, modified 6 Years ago.
RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme
Liferay Legend Posts: 2416 Join Date: 12/22/10 Recent Posts
Ok -- this is odd. I changed my code so that I am not resetting the preferences. So the code looks like this --
.. and now the preferences are being saved. SO perhaps the answer is to call the reset BEFORE the preference values are set (to make sure that you have a blank map). Doing it after seems to suggest that a <blank> is what the portal is seeing. Weird.
<#assign VOID = freeMarkerPortletPreferences.setValue("searchScope", "everything") />
<@liferay.search default_preferences="${freeMarkerPortletPreferences}" />
<#--<#assign VOID = freeMarkerPortletPreferences.reset() />-->
.. and now the preferences are being saved. SO perhaps the answer is to call the reset BEFORE the preference values are set (to make sure that you have a blank map). Doing it after seems to suggest that a <blank> is what the portal is seeing. Weird.
Clark Nelson, modified 6 Years ago.
RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme
New Member Posts: 5 Join Date: 8/15/17 Recent Posts
I am also trying to implement setting a default ADT for breadcrumbs at a theme level.
This is how I am trying to do so in my portal_normal.ftl
Where "displayStyle" and "displayStyleGroupId" are defined in the "ddmtemplate" table in the database for my ADT. I have tried many variations and to my frustration almost nothing works. Not even the portlet decorator works as expected (from the docs). Please help!
This is how I am trying to do so in my portal_normal.ftl
<nav id="breadcrumbs">
<#assign VOID = freeMarkerPortletPreferences.setValue("portletSetupPortletDecoratorId", "borderless")>
<#assign VOID = freeMarkerPortletPreferences.setValue("displayStyle", "ddmTemplate_838501")>
<#assign VOID = freeMarkerPortletPreferences.setValue("displayStyleGroupId", "10180")>
<@liferay.breadcrumbs default_preferences="${freeMarkerPortletPreferences}"/>
<#-- <@liferay_portlet["runtime"]
defaultPreferences="freeMarkerPortletPreferences"
portletProviderAction=portletProviderAction.VIEW
portletProviderClassName="com.liferay.portal.kernel.servlet.taglib.ui.BreadcrumbEntry"
/> -->
<#-- <#assign VOID = freeMarkerPortletPreferences.reset()> -->
</nav>
Where "displayStyle" and "displayStyleGroupId" are defined in the "ddmtemplate" table in the database for my ADT. I have tried many variations and to my frustration almost nothing works. Not even the portlet decorator works as expected (from the docs). Please help!
Clark Nelson, modified 6 Years ago.
RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme
New Member Posts: 5 Join Date: 8/15/17 Recent Posts
Printing out ${freeMarkerPortletPreferences} looks something like this:
Not sure where I can find a reference to this in the database or really what it means. The borderless part will change when I change the value of "portletSetupPortletDecoratorId", but it does not actually change the breadcrumbs decorator.
displayStyleddmTemplate_838501displayStyleGroupId10180portletSetupPortletDecoratorIdborderless
Not sure where I can find a reference to this in the database or really what it means. The borderless part will change when I change the value of "portletSetupPortletDecoratorId", but it does not actually change the breadcrumbs decorator.
Clark Nelson, modified 6 Years ago.
RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme
New Member Posts: 5 Join Date: 8/15/17 Recent Posts
Looks like the settings / preferences are stored somewhere, yet that is not explained in the post
https://web.liferay.com/fr/community/forums/-/message_boards/message/101377031
I would love to know where the portlet preferences are stored so I can clear the preferences. Clearing the `portletpreferences` table in the database does nothing (go figure).
Other relevant links and references:
https://github.com/Vastra-Gotalandsregionen/glasogonbidrag-theme/blob/master/core-bc/modules/theme/src/main/webapp/templates/init_custom.ftl
The documentation might be wrong!
https://issues.liferay.com/browse/LPS-67974
https://web.liferay.com/fr/community/forums/-/message_boards/message/101377031
I would love to know where the portlet preferences are stored so I can clear the preferences. Clearing the `portletpreferences` table in the database does nothing (go figure).
Other relevant links and references:
https://github.com/Vastra-Gotalandsregionen/glasogonbidrag-theme/blob/master/core-bc/modules/theme/src/main/webapp/templates/init_custom.ftl
<#assign void = portletPreferencesLocalService.updatePreferences(0, 3, page_plid, portletInstanceId, settingsXml) />
${freeMarkerPortletPreferences.reset()}
${freeMarkerPortletPreferences.setValue("portletSetupShowBorders","false")}
${theme.runtime(portletInstanceId, "", freeMarkerPortletPreferences)}
${freeMarkerPortletPreferences.reset()}
The documentation might be wrong!
https://issues.liferay.com/browse/LPS-67974
Clark Nelson, modified 5 Years ago.
RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme
New Member Posts: 5 Join Date: 8/15/17 Recent Posts
I am bumping this issue, I would really like to set the ADT programmatically in the freemarker file!
Emilio Sánchez, modified 5 Years ago.
RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme
New Member Posts: 10 Join Date: 10/30/18 Recent Posts
Hi,
Did you find any solution about this?
I would like to set the display of a portlet in runtime.
Thanks.
Did you find any solution about this?
I would like to set the display of a portlet in runtime.
Thanks.
John Feeney, modified 5 Years ago.
RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme
New Member Posts: 2 Join Date: 9/16/16 Recent PostsIn case anyone is looking for this in future. Here's an example of setting preferences for the Search Bar portlet macro in DXP 7.1 -
<#assign preferencesMap = {"scopeParameterName": "scope", "searchScope": "this-site", "keywordsParameterName": "q", "destination": "/search", "useAdvancedSearchSyntax": false} />
<@liferay.search_bar
default_preferences=freeMarkerPortletPreferences.getPreferences(preferencesMap) />
Abhishek Jain, modified 5 Years ago.
RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme
Regular Member Posts: 226 Join Date: 8/20/16 Recent PostsI could not get the preferences( set through freeMarkerPortletPreferences ) inside jsp file...Any idea?
Lee Jordan, modified 4 Years ago.
RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme
Expert Posts: 449 Join Date: 5/26/15 Recent Posts
I looked at this in 2016 and gave up. I'm looking at it again in 2020 and am giving up again.
Basically nothing works!! So to set the template for breadcrumb, I just edited the default ADT template for breadcrumb (horizontal.ftl) so it messes up the documents and media and everywhere else the breadcrumb is used. Oh well. Come on Liferay live our life!! It sucks!
Sucks to work on Liferay Front End ... no documentation whatsoever.
Basically nothing works!! So to set the template for breadcrumb, I just edited the default ADT template for breadcrumb (horizontal.ftl) so it messes up the documents and media and everywhere else the breadcrumb is used. Oh well. Come on Liferay live our life!! It sucks!
Sucks to work on Liferay Front End ... no documentation whatsoever.
Neil Griffin, modified 3 Years ago.
RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme
Liferay Legend Posts: 2655 Join Date: 7/27/05 Recent Posts
I recently had to embed a Navigation Menu portlet in a Liferay 7.2 theme's freemarker template and set portlet preferences, which seemed pretty similar to this. For more information, see the blog post that I wrote.