RE: Adding Widgets to Page Fragments

thumbnail
Nick Burton, modified 6 Years ago. Junior Member Posts: 51 Join Date: 7/13/14 Recent Posts
Sorry if this is obvious ...

Question:  Where/how do I find the registered Alias for each widget?

For example, I have tried to add <lfr-widget-login></lfr-widget-login> for the Login Widget, but the screen simply displays — "There is no widget available for alias login".
I don't know how to find the correct registered Alias for each widget/portlet.

Thanks in advance.


Nick
thumbnail
Dave Kliczbor, modified 5 Years ago. Junior Member Posts: 77 Join Date: 7/12/11 Recent Posts
What I found out about this:
  1. Browse to https://github.com/liferay/liferay-portal
  2. Press T
  3. Enter the Portlet Class file name("LoginPortlet.java")
  4. Look for the value of the @Component property "com.liferay.fragment.entry.processor.portlet.alias"
  5. Prefix that value with "lfr-widget-", then you've got your tag name.
  6. Realize that the @Component property for LoginPortlet from step 4 is not there.
  7. Go to https://issues.liferay.com and file a bug.
  8. Wait one or two Liferay releases.
  9. Redo 1-5, then continue developing.
I just went through the same problem as you, except that I found out that for a Portlet to be accessible using <lfr-widget-*>, the Portlet class needs to have the @Component property mentioned above.
BUT, there is an alternative way to get a portlet into a page fragment (which even gives you the opportunity to preconfigure it -- just omit the preferences parts if you don't need that):
[code]<div class="fragment-12345">
  [#assign assetPublisherPortletPreferences="<portlet-preferences>
    <preference>
        <name>delta</name>
        <value>12</value>
    </preference>
</portlet-preferences>" /]
  [@liferay_portlet["runtime"]
    instanceId="${fragmentEntryLinkNamespace}assets"
    portletName="com_liferay_asset_publisher_web_portlet_AssetPublisherPortlet"
    defaultPreferences="${assetPublisherPortletPreferences}"
  /]
</div>
The info that's nowhere to be found (unless you read Liferays source code) is that Page Fragments' HTML actually is processed by Freemarker, but only Freemarkers alternative syntax is allowed here. So, we can make use of Liferay taglibs here, which puts the tag
<liferay-portlet:runtime> </liferay-portlet:runtime>
in our reach.
thumbnail
Christoph Rabel, modified 5 Years ago. Liferay Legend Posts: 1555 Join Date: 9/24/09 Recent Posts