Liferay 7 - Add Web Content in ThemeLiferay 7 - Add Web Content in Themehttps://liferay.dev/en/c/message_boards/find_thread?p_l_id=119785333&threadId=760238122024-03-29T10:08:38Z2024-03-29T10:08:38ZRE: Liferay 7 - Add Web Content in ThemeLee Jordanhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1186191602020-02-28T20:09:16Z2020-02-28T20:09:16ZThat would work for sure, but I have 500 sites. Nobody on my team is going to go through 500 sites setting a theme setting, multiply that by 3 because we have three environments. Nope. The issue as stated with the article ID, it's going to be different between three environments, so you can't deploy the theme to different environments with an article ID hard-coded. <br /><br />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!!!<br /><br />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.<br /><br />I am using theme settings though to allow users to hide show UI elements though.Lee Jordan2020-02-28T20:09:16ZRE: Liferay 7 - Add Web Content in ThemeFernando Fernandezhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1183559862020-01-28T10:46:08Z2020-01-28T10:46:08Z<html><head></head><body>Since this is the first result in a google search for this subject I think it's useful too add that since some time ago you can use the <a href="https://portal.liferay.dev/docs/7-2/reference/-/knowledge_base/r/freemarker-taglib-macros">JSP taglibs in freemarker</a>. <br>This means that, to display an article in the footer you can include something like this in your theme's portal_normal.ftl:<br><br><pre><code>&lt;@liferay_journal["journal-article"]
&nbsp; articleId=footer_article_id
&nbsp; groupId=page_group.groupId
/&gt;</code></pre><br>Additionally, if you want to use a theme setting config you must:<br> <br>1. Add the setting to the <strong>liferay-look-and-feel.xml</strong> file from your theme<br><br><pre><code><settings>
&nbsp; &nbsp; <setting configurable="true" key="footer-article-id" type="text" />
</settings></code></pre><br>2. Convert the setting into a variable in <strong>init_custom.ftl</strong><br><pre><code>&lt;#assign&nbsp;footer_article_id&nbsp;=&nbsp;getterUtil.getString(themeDisplay.getThemeSetting("footer-article-id"))/&gt;</code></pre><br>HTH<br><br>Fernando</body></html>Fernando Fernandez2020-01-28T10:46:08ZRE: Liferay 7 - Add Web Content in ThemeLee Jordanhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1147655052019-08-14T19:45:26Z2019-08-14T19:45:26ZThis was a frustrating read ... the OP isn't wanting to embed a portlet but a web content article. I would like to do this to add a global footer links section in 7.0 but the trouble would be that the article ID's would be different on DEV QA and Production servers. I looked at adding the article ID in the look-and-feel.xml as a theme custom field, that didn't seem to work.Lee Jordan2019-08-14T19:45:26ZRE: Liferay 7 - Add Web Content in ThemeAritz Galdoshttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1120780522019-01-21T15:04:02Z2019-01-21T15:04:02Z<p>Hi,</p>
<p> </p>
<p>Here a link to some documentation.</p>
<p> </p>
<p>https://dev.liferay.com/es/develop/tutorials/-/knowledge_base/7-1/embedding-portlets-in-themes-and-layout-templates</p>Aritz Galdos2019-01-21T15:04:02ZRE: Liferay 7 - Add Web Content in ThemeRashesh Vedhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1120684232019-01-21T10:08:22Z2019-01-21T10:08:22Z<p>Hii your reply help me alot.</p>
<p>
<br /> 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?<br />
<br /> In my freemarker theme template I tried to access
J<strong>ournalArticleLocalServiceUtil </strong> in following manner
it is showing me error mentioning null or missing serviceLocator<br />
<br /> <#assign journalArticleLocalServiceUtil = serviceLocator.findService("com.liferay.journal.service.JournalArticleLocalServiceUtil")><br />
<br /> I tried to remove all restricted variables as well from front
side and restarted server still it's showing same error.</p>Rashesh Ved2019-01-21T10:08:22ZRE: Liferay 7 - Add Web Content in ThemeErik Cochranhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=857580252017-02-08T06:37:04Z2017-02-08T06:37:04ZHi Manushi,<br />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.<br />E.Erik Cochran2017-02-08T06:37:04ZRE: Liferay 7 - Add Web Content in ThemeManushi Janihttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=813324612016-10-17T15:30:02Z2016-10-17T15:30:02Z<#assign VOID = freeMarkerPortletPreferences.setValue("portletSetupPortletDecoratorId", "barebone") /><br /><#assign theme_groupID = htmlUtil.escape(theme_display.getCompanyGroupId()?string) /><br /><#assign VOID = freeMarkerPortletPreferences.setValue("groupId", "yourscopegroupid") /><br /><#assign VOID = freeMarkerPortletPreferences.setValue("articleId", "yourarticleid") /><br /><br /> <@liferay_portlet["runtime"]<br /> defaultPreferences="${freeMarkerPortletPreferences}"<br /> portletProviderAction=portletProviderAction.VIEW<br /> instanceId="anynameyoucangive"<br /> portletName="com_liferay_journal_content_web_portlet_JournalContentPortlet" /><br /> ${freeMarkerPortletPreferences.reset()}<br /> <br /></div><br /><br />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.Manushi Jani2016-10-17T15:30:02ZRE: Liferay 7 - Add Web Content in ThemeMatteo Gnocchihttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=764732312016-07-11T12:55:45Z2016-07-11T12:55:45ZIt works perfectly!<br />Thank you very Much!!!!Matteo Gnocchi2016-07-11T12:55:45ZRE: Liferay 7 - Add Web Content in Themeteodor popescuhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=764619682016-07-11T08:44:42Z2016-07-11T08:44:42ZWhat about embedding into Velocity themes?<br />Has anyone managed to find a solution?<br /><br />Thanks!teodor popescu2016-07-11T08:44:42ZRE: Liferay 7 - Add Web Content in ThemeMichele Stodutohttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=763320562016-07-06T21:19:11Z2016-07-06T21:19:11Z<html><head></head><body>i've a possible solution, use runtime portlet into theme:<br><br><br><pre><code>&lt;#assign VOID = freeMarkerPortletPreferences.setValue("portletSetupPortletDecoratorId", "barebone")&gt;
&lt;@liferay_portlet["runtime"]
defaultPreferences="${freeMarkerPortletPreferences}"
portletProviderAction=portletProviderAction.VIEW
portletName="com_liferay_journal_content_web_portlet_JournalContentPortlet" /&gt;
${freeMarkerPortletPreferences.reset()}</code></pre><br><br>the code is valid for a single portlet (Web Content) into theme.<br>If you want a multi portlet (Web Content) add instanceIdinto tag.<br><br><pre><code>&lt;#assign VOID = freeMarkerPortletPreferences.setValue("portletSetupPortletDecoratorId", "barebone")&gt;
&lt;@liferay_portlet["runtime"]
defaultPreferences="${freeMarkerPortletPreferences}"
portletProviderAction=portletProviderAction.VIEW
instanceId="blablabla1"
portletName="com_liferay_journal_content_web_portlet_JournalContentPortlet" /&gt;
${freeMarkerPortletPreferences.reset()}</code></pre></body></html>Michele Stoduto2016-07-06T21:19:11ZRE: Liferay 7 - Add Web Content in ThemeMichele Stodutohttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=762644192016-07-05T09:06:41Z2016-07-05T09:06:41ZHi Matteo <br />I've a similar problem for embedded web content in theme. <br />Have you find any solution?<br />Can you write the solution?<br /><br />TnxMichele Stoduto2016-07-05T09:06:41ZRE: Liferay 7 - Add Web Content in ThemeMatteo Gnocchihttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=760623632016-06-30T08:38:14Z2016-06-30T08:38:14ZThanks Travis<br />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"<br />Have you been able to use it?<br />MatteoMatteo Gnocchi2016-06-30T08:38:14ZRE: Liferay 7 - Add Web Content in ThemeTravis Coryhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=760387782016-06-29T16:25:51Z2016-06-29T16:25:51Z<html><head></head><body>Hey Matteo,<br><br>Sorry for the frustration. I'd try to see if you can use the Impl class and <a href="https://github.com/liferay/liferay-portal/blob/master/modules/apps/web-experience/journal/journal-service/src/main/java/com/liferay/journal/util/impl/JournalContentImpl.java#L144-L147">this method</a>. If calling <pre><code>${journalContentImpl}</code></pre> doesn't work try calling <pre><code>${journalContent}</code></pre> If you have article Id you can pass in the other variables really easily with variables from <a href="https://github.com/liferay/liferay-portal/blob/master/modules/apps/foundation/frontend-theme/frontend-theme-unstyled/src/main/resources/META-INF/resources/_unstyled/templates/init.ftl">init.ftl</a></body></html>Travis Cory2016-06-29T16:25:51ZLiferay 7 - Add Web Content in Theme