掲示板

Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme

thumbnail
7年前 に Sandip Patel によって更新されました。

Set Preference for Embedded Asset Publisher portlet in Liferay 7 Theme

Regular Member 投稿: 205 参加年月日: 11/01/05 最新の投稿
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
7年前 に pratik parekh によって更新されました。

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

New Member 投稿: 18 参加年月日: 14/09/09 最新の投稿
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
3年前 に Eduardo P. García によって更新されました。

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

Regular Member 投稿: 157 参加年月日: 12/03/16 最新の投稿
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
7年前 に A G によって更新されました。

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

New Member 投稿: 14 参加年月日: 17/02/01 最新の投稿
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!!
7年前 に Jacopo Bartolini によって更新されました。

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

Junior Member 投稿: 28 参加年月日: 17/01/19 最新の投稿
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
7年前 に A G によって更新されました。

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

New Member 投稿: 14 参加年月日: 17/02/01 最新の投稿
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
6年前 に Andrew Jardine によって更新されました。

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

Liferay Legend 投稿: 2416 参加年月日: 10/12/22 最新の投稿
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
6年前 に Andrew Jardine によって更新されました。

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

Liferay Legend 投稿: 2416 参加年月日: 10/12/22 最新の投稿
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.
6年前 に Clark Nelson によって更新されました。

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

New Member 投稿: 5 参加年月日: 17/08/15 最新の投稿
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!
6年前 に Clark Nelson によって更新されました。

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

New Member 投稿: 5 参加年月日: 17/08/15 最新の投稿
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.
6年前 に Clark Nelson によって更新されました。

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

New Member 投稿: 5 参加年月日: 17/08/15 最新の投稿
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
5年前 に Clark Nelson によって更新されました。

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

New Member 投稿: 5 参加年月日: 17/08/15 最新の投稿
I am bumping this issue, I would really like to set the ADT programmatically in the freemarker file! emoticon
5年前 に Emilio Sánchez によって更新されました。

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

New Member 投稿: 10 参加年月日: 18/10/30 最新の投稿
Hi,

Did you find any solution about this?

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

​​​​​​​Thanks.
thumbnail
5年前 に John Feeney によって更新されました。

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

New Member 投稿: 2 参加年月日: 16/09/16 最新の投稿

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
5年前 に Abhishek Jain によって更新されました。

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

Regular Member 投稿: 226 参加年月日: 16/08/20 最新の投稿

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

4年前 に Lee Jordan によって更新されました。

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

Expert 投稿: 449 参加年月日: 15/05/26 最新の投稿
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
3年前 に Neil Griffin によって更新されました。

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

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
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.