Foros de discusión

RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme

thumbnail
Sandip Patel, modificado hace 7 años.

Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme

Regular Member Mensajes: 205 Fecha de incorporación: 5/01/11 Mensajes recientes
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
pratik parekh, modificado hace 7 años.

RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme

New Member Mensajes: 18 Fecha de incorporación: 9/09/14 Mensajes recientes
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 :

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.
thumbnail
Eduardo P. García, modificado hace 3 años.

RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme

Regular Member Mensajes: 157 Fecha de incorporación: 16/03/12 Mensajes recientes
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.


&lt;#assign VOID = freeMarkerPortletPreferences.setValue("displayStyle", "my_global_adt_key")&gt;
&lt;#assign VOID = freeMarkerPortletPreferences.setValue("displayStyleGroupId", themeDisplay.getCompanyGroupId()?string)&gt;
&lt;@liferay_portlet["runtime"]
		defaultPreferences=freeMarkerPortletPreferences
		portletProviderAction=portletProviderAction.VIEW
		portletProviderClassName="com.liferay.asset.kernel.model.AssetEntry"
	/&gt;

&lt;#assign VOID = freeMarkerPortletPreferences.reset()&gt;


I hope this helps.

Regards
A G, modificado hace 7 años.

RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme

New Member Mensajes: 14 Fecha de incorporación: 1/02/17 Mensajes recientes
Hello
I´m trying to use the code you provided for changing breadcrumbs display in this way:


              &lt;#assign VOID = freeMarkerPortletPreferences.setValue("displayStyle", "ddmTemplate_36706")&gt;
		&lt;#assign VOID = freeMarkerPortletPreferences.setValue("displayStyleGroupId", themeDisplay.getCompanyGroupId()?string)&gt;

		&lt;@liferay_portlet["runtime"]
				defaultPreferences="${freeMarkerPortletPreferences}"
				portletProviderAction=portletProviderAction.VIEW
				portletProviderClassName="com.liferay.portal.kernel.servlet.taglib.ui.BreadcrumbEntry"
			/&gt;


Alternatively, I have tried with this code (and with the same freeMarkerPortletPreferences ):

&lt;@liferay.breadcrumbs default_preferences="${freeMarkerPortletPreferences}" /&gt;


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, modificado hace 7 años.

RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme

Junior Member Mensajes: 28 Fecha de incorporación: 19/01/17 Mensajes recientes
Sandip 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, modificado hace 7 años.

RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme

New Member Mensajes: 14 Fecha de incorporación: 1/02/17 Mensajes recientes
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 emoticon

If I reach any conclusion, I will write it here.
Please, If you get it, let me know.

Thanks in advance
thumbnail
Andrew Jardine, modificado hace 6 años.

RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme

Liferay Legend Mensajes: 2416 Fecha de incorporación: 22/12/10 Mensajes recientes
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.


&lt;#assign VOID = freeMarkerPortletPreferences.setValue("searchScope", "everything") /&gt;
&lt;@liferay.search default_preferences="${freeMarkerPortletPreferences}" /&gt;
&lt;#assign VOID = freeMarkerPortletPreferences.reset() /&gt;


.. I checked the Liferay source and found --

&lt;#macro search
	default_preferences = ""
&gt;
	&lt;#if is_setup_complete&gt;
		&lt;@liferay_portlet["runtime"]
			defaultPreferences=default_preferences
			portletProviderAction=portletProviderAction.VIEW
			portletProviderClassName="com.liferay.admin.kernel.util.PortalSearchApplicationType$Search"
		/&gt;
	<!--#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.
thumbnail
Andrew Jardine, modificado hace 6 años.

RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme

Liferay Legend Mensajes: 2416 Fecha de incorporación: 22/12/10 Mensajes recientes
Ok -- this is odd. I changed my code so that I am not resetting the preferences. So the code looks like this --

  &lt;#assign VOID = freeMarkerPortletPreferences.setValue("searchScope", "everything") /&gt;
                &lt;@liferay.search default_preferences="${freeMarkerPortletPreferences}" /&gt;
                &lt;#--&lt;#assign VOID = freeMarkerPortletPreferences.reset() /&gt;--&gt;


.. 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, modificado hace 6 años.

RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme

New Member Mensajes: 5 Fecha de incorporación: 15/08/17 Mensajes recientes
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


<nav id="breadcrumbs">
    &lt;#assign VOID = freeMarkerPortletPreferences.setValue("portletSetupPortletDecoratorId", "borderless")&gt;
    &lt;#assign VOID = freeMarkerPortletPreferences.setValue("displayStyle", "ddmTemplate_838501")&gt;
    &lt;#assign VOID = freeMarkerPortletPreferences.setValue("displayStyleGroupId", "10180")&gt;
    &lt;@liferay.breadcrumbs default_preferences="${freeMarkerPortletPreferences}"/&gt;
    &lt;#-- &lt;@liferay_portlet["runtime"]
          defaultPreferences="freeMarkerPortletPreferences"
          portletProviderAction=portletProviderAction.VIEW
          portletProviderClassName="com.liferay.portal.kernel.servlet.taglib.ui.BreadcrumbEntry"
     /&gt; --&gt;
     &lt;#-- &lt;#assign VOID = freeMarkerPortletPreferences.reset()&gt; --&gt;
</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, modificado hace 6 años.

RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme

New Member Mensajes: 5 Fecha de incorporación: 15/08/17 Mensajes recientes
Printing out ${freeMarkerPortletPreferences} looks something like this:
 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, modificado hace 6 años.

RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme

New Member Mensajes: 5 Fecha de incorporación: 15/08/17 Mensajes recientes
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

&lt;#assign void = portletPreferencesLocalService.updatePreferences(0, 3, page_plid, portletInstanceId, settingsXml) /&gt;
${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, modificado hace 5 años.

RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme

New Member Mensajes: 5 Fecha de incorporación: 15/08/17 Mensajes recientes
I am bumping this issue, I would really like to set the ADT programmatically in the freemarker file! emoticon
Emilio Sánchez, modificado hace 5 años.

RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme

New Member Mensajes: 10 Fecha de incorporación: 30/10/18 Mensajes recientes
Hi,

Did you find any solution about this?

I would like to set the display of a portlet in runtime.

​​​​​​​Thanks.
thumbnail
John Feeney, modificado hace 5 años.

RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme

New Member Mensajes: 2 Fecha de incorporación: 16/09/16 Mensajes recientes

In 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) />

thumbnail
Abhishek Jain, modificado hace 5 años.

RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme

Regular Member Mensajes: 226 Fecha de incorporación: 20/08/16 Mensajes recientes

I could not get the preferences( set through freeMarkerPortletPreferences ) inside jsp file...Any idea?

Lee Jordan, modificado hace 4 años.

RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme

Expert Mensajes: 449 Fecha de incorporación: 26/05/15 Mensajes recientes
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.
thumbnail
Neil Griffin, modificado hace 4 años.

RE: Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme

Liferay Legend Mensajes: 2655 Fecha de incorporación: 27/07/05 Mensajes recientes
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.