Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: How to change the look and feel of embedded portlet?
Hi,
I have a custom-layout.tpl in my theme, and right now I am trying to add a BreadCrumb Portlet to my layout. To add it, I am doing like this:
This is adding my portlet just like I want, but I would love to add it as Barebone. Is there any way to pass this value in my tpl file?
I have a custom-layout.tpl in my theme, and right now I am trying to add a BreadCrumb Portlet to my layout. To add it, I am doing like this:
<div class="my-css-class">
$processor.processPortlet("com_liferay_site_navigation_breadcrumb_web_portlet_SiteNavigationBreadcrumbPortlet")
</div>
This is adding my portlet just like I want, but I would love to add it as Barebone. Is there any way to pass this value in my tpl file?
In Liferay 7, It should be possible in a way similar to this (I did not test yet):
Docs: https://portal.liferay.dev/docs/7-0/tutorials/-/knowledge_base/t/applying-portlet-decorators-to-embedded-portlets
<#assign preferences = freeMarkerPortletPreferences.getPreferences({"portletSetupPortletDecoratorId" : "barebone"}) />
<@liferay_portlet["runtime"]
defaultPreferences="${preferences}"
portletName="com_liferay_site_navigation_breadcrumb_web_portlet_SiteNavigationBreadcrumbPortlet"
/>
Docs: https://portal.liferay.dev/docs/7-0/tutorials/-/knowledge_base/t/applying-portlet-decorators-to-embedded-portlets
Hi Alfonso,
Thanks for the answer. This code you quote works indeed in the ftl file format. But what I was looking for was for the tpl file. I know that I asked for ftl, but it was a mistake typing. I will edit the post.
Thanks for the answer. This code you quote works indeed in the ftl file format. But what I was looking for was for the tpl file. I know that I asked for ftl, but it was a mistake typing. I will edit the post.
Hi Ricardo,
No problem. Again, without testing myself, something like this might help:
No problem. Again, without testing myself, something like this might help:
$theme.runtime("mytest_INSTANCE_1234", "", "")
#set($VOID = $velocityPortletPreferences.reset())
#set($VOID = $velocityPortletPreferences.setValue('portletSetupPortletDecoratorId', 'barebone'))
$theme.runtime("mytest_INSTANCE_1234", "", $velocityPortletPreferences.toString())
#set($VOID = $velocityPortletPreferences.reset())
$processor.processColumn("column-1", "portlet-column-content portlet-column-content-last")
Also, just as info, as of https://issues.liferay.com/browse/LPS-75190, layout templates can also be .ftl (Freemarker) instead of .tpl. You can change the file extension of file e.g. docroot/test.tpl to .ftl and the template-path to .ftl in the file docroot/WEB-INF/liferay-layout-templates.xml.
Hi Alfonso,
I could add the portlet with your solution, but I could not change the preferences this way. So I tried to change from tpl to ftl format and I could do something like this:
The problem is that "liferay_portlet" is null or missing:
Am I missing some include? How could this be missing?
I could add the portlet with your solution, but I could not change the preferences this way. So I tried to change from tpl to ftl format and I could do something like this:
<div class="my-breadcrumb-css">
<#assign preferences = freeMarkerPortletPreferences.getPreferences("portletSetupPortletDecoratorId", "barebone") />
<@liferay_portlet["runtime"]
defaultPreferences="${preferences}"
portletName="com_liferay_site_navigation_breadcrumb_web_portlet_SiteNavigationBreadcrumbPortlet" />
</div>
<div class="my-column-css">
${processor.processColumn("column-1", "portlet-column-content")}
</div>
The problem is that "liferay_portlet" is null or missing:
FreeMarker template error:
The following has evaluated to null or missing:
==> liferay_portlet [in template "my_theme_CUSTOM_layout_simple" at line 5, column 27]----
Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing<!--#if-->. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
--------
FTL stack trace ("~" means nesting-related):
- Failed at: @liferay_portlet["runtime"] defaultPr... [in template "my_theme_CUSTOM_layout_simple" at line 5, column 25]
----
Am I missing some include? How could this be missing?
Ok. So I could not find any solution for my problem and I went back to velocity (tpl). I also found out that you can add breadcrumbs with:
I can't find any documentation for this. I suppose that the params are the same as the configuration options that the default Breadcrumb portlet have, but I am unsure about the first param (the String one).
$theme.breadcrumb("", false, false, true, true)
I can't find any documentation for this. I suppose that the params are the same as the configuration options that the default Breadcrumb portlet have, but I am unsure about the first param (the String one).
Hi Fabio, sorry for the delay, I was at DEVCON earlier this week. How about this (Velocity/tpl) approach?
<div class="my-liferay-layout" id="main-content" role="main">
<div class="portlet-layout row">
<div class="col-md-12 portlet-column portlet-column-only" id="column-1">
$velocityPortletPreferences.setValue("portletSetupPortletDecoratorId", "barebone")
$theme.runtime("com_liferay_site_navigation_breadcrumb_web_portlet_SiteNavigationBreadcrumbPortlet", "",
$velocityPortletPreferences.toString())
$velocityPortletPreferences.reset()
</div>
</div>
</div>
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™