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: Liferay 7 - Add Web Content in Theme
I'd like to add a web content in my theme (FreeMarker) for Liferay 7.
I tried to use the "journalContentUtil.getContent" method but it didn't work.
Probably the journalContentUtil does not exist in liferay 7 anymore (see more)
How can I embed a webcontent in my freemarker theme for Liferay 7?
Thanks!!
Sorry for the frustration. I'd try to see if you can use the Impl class and this method. If calling
${journalContentImpl}
doesn't work try calling ${journalContent}
If you have article Id you can pass in the other variables really easily with variables from init.ftl
Probably I'm doing something wrong but when I try to use "${journalContent}" I get this error: "The following has evaluated to null or missing"
Have you been able to use it?
Matteo
I've a similar problem for embedded web content in theme.
Have you find any solution?
Can you write the solution?
Tnx
<#assign VOID = freeMarkerPortletPreferences.setValue("portletSetupPortletDecoratorId", "barebone")>
<@liferay_portlet["runtime"]
defaultPreferences="${freeMarkerPortletPreferences}"
portletProviderAction=portletProviderAction.VIEW
portletName="com_liferay_journal_content_web_portlet_JournalContentPortlet" />
${freeMarkerPortletPreferences.reset()}
the code is valid for a single portlet (Web Content) into theme.
If you want a multi portlet (Web Content) add instanceIdinto tag.
<#assign VOID = freeMarkerPortletPreferences.setValue("portletSetupPortletDecoratorId", "barebone")>
<@liferay_portlet["runtime"]
defaultPreferences="${freeMarkerPortletPreferences}"
portletProviderAction=portletProviderAction.VIEW
instanceId="blablabla1"
portletName="com_liferay_journal_content_web_portlet_JournalContentPortlet" />
${freeMarkerPortletPreferences.reset()}
Has anyone managed to find a solution?
Thanks!
Thank you very Much!!!!
<#assign theme_groupID = htmlUtil.escape(theme_display.getCompanyGroupId()?string) />
<#assign VOID = freeMarkerPortletPreferences.setValue("groupId", "yourscopegroupid") />
<#assign VOID = freeMarkerPortletPreferences.setValue("articleId", "yourarticleid") />
<@liferay_portlet["runtime"]
defaultPreferences="${freeMarkerPortletPreferences}"
portletProviderAction=portletProviderAction.VIEW
instanceId="anynameyoucangive"
portletName="com_liferay_journal_content_web_portlet_JournalContentPortlet" />
${freeMarkerPortletPreferences.reset()}
</div>
Using this code exactly,you can embed the desired journal article(by passing the articleid) in web content display.Please don't forget to include the line instanceId="anynameyoucangive",otherwise it won't reflect.I wasted much time and found this.Hence it is very helpful.
How did you figure this out? Also, shouldn't the articleId and instanceId match? I found that another developer placed the instanceId in articleId but captilized the variable. Any reference documentation is much appreciated.
E.
Hi,
Here a link to some documentation.
https://dev.liferay.com/es/develop/tutorials/-/knowledge_base/7-1/embedding-portlets-in-themes-and-layout-templates
Hii your reply help me alot.
But can you please tell me in this article Id portion if i want
to get article Id dynamically then how can I do it?
In my freemarker theme template I tried to access
JournalArticleLocalServiceUtil in following manner
it is showing me error mentioning null or missing serviceLocator
<#assign journalArticleLocalServiceUtil = serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalServiceUtil")>
I tried to remove all restricted variables as well from front
side and restarted server still it's showing same error.
This means that, to display an article in the footer you can include something like this in your theme's portal_normal.ftl:
<@liferay_journal["journal-article"]
articleId=footer_article_id
groupId=page_group.groupId
/>
Additionally, if you want to use a theme setting config you must:
1. Add the setting to the liferay-look-and-feel.xml file from your theme
<settings>
<setting configurable="true" key="footer-article-id" type="text" />
</settings>
2. Convert the setting into a variable in init_custom.ftl
<#assign footer_article_id = getterUtil.getString(themeDisplay.getThemeSetting("footer-article-id"))/>
HTH
Fernando
Also ... defaultPreferences="${freeMarkerPortletPreferences}" doesn't seem to work and there's zero helpful documentation, beyond setting the decorator to borderless. Which ok is helpful but that one example doesn't then tell anyone how to access actual portlet configurations, there's no codex or index of these possibilities, in fact there is zero documentation on the inbuilt portlets for developers period. Liferay documentation is written with a lot of assumptions by people who are close to Liferay. Nobody else has a chance with the documentation. Litterally the documentation is ok you can set barebones, you're a pro!!!
The only suggestion seems to be to get the portlet preferences by looking at the database? A front end developer is not going to be looking at a database table, sorry they just won't.
I am using theme settings though to allow users to hide show UI elements though.
Powered by Liferay™