Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Sandeep Nair
Embedding webcontent in Theme behavior
August 16, 2012 8:02 AM
Answer

Sandeep Nair

Rank: Liferay Legend

Posts: 1721

Join Date: November 5, 2008

Recent Posts

Hi,

I am trying to embed webcontent in theme. I want it flexible so that end users can go and change the webcontent. So I used the following snippet of the code.

$velocityPortletPreferences.setValue("portlet-setup-show-borders", "false")
$velocityPortletPreferences.setValue("groupid","group_id")
$theme.runtime($my_portlet_id, "", $velocityPortletPreferences.toString())
$velocityPortletPreferences.reset()

The above snippet is perfectly working fine and I am able to see the webcontent display portlet on every page. Now if I select a web content on one of the pages, the same doesnt get shown in other pages. Which means I need to select web content for each and every page.

Is it possible to have same article that i select in any one of the pages gets replicated to other pages. I am using Liferay 5.2 EE SP4

Note: I dont want to set article id as one of the preferences. Since this will be sort of hardcoding, and on every environment I have to manage the same.

Regards,
Sandeep
Sagar A Vyas
RE: Embedding webcontent in Theme behavior
August 16, 2012 11:30 AM
Answer

Sagar A Vyas

Rank: Liferay Master

Posts: 657

Join Date: April 17, 2009

Recent Posts

Sandeep,

As you know WebContentDisplay portlet is instanceable portlet and it will hold the content and that instance gets change page by page.

Now as per your requirement you need to set footer webcontent through out the site,rather want webcontentdisplay portlet through the site emoticon

In this case you can use following approach I know you don't want hardcode things but I guess you can use webcontent urlTitle.

Please find code snippet use this in portal_navigation.vm

1
2#set ($journalArticleLocalService = $serviceLocator.findService("com.liferay.portlet.journal.service.JournalArticleLocalService"))
3#set ($journalContentUtil = $utiLocator.findUtil("com.liferay.portlet.journalcontent.util.JournalContentUtil"))
4#set ($footerMenuURLTitle = "footer-content")
5#set ($journalArticle = $journalArticleLocalService.getLatestArticleByUrlTitle($themeDisplay.getScopeGroupId(),$footerMenuURLTitle, 0))
6$journalContentUtil.getContent($group_id,$journalArticle.getArticleId() ,null,$locale.toString(),$theme_display)


Above code will read content and paste on footer instead of WCD,I would prefer this way.

And this content would be same through out the site so nothing like hardcode,or you can create this content on GOLBAL level so need to create it on every communities even.

Hope this help emoticon

Thanks,
Sagar Vyas
Sandeep Nair
RE: Embedding webcontent in Theme behavior
August 16, 2012 12:19 PM
Answer

Sandeep Nair

Rank: Liferay Legend

Posts: 1721

Join Date: November 5, 2008

Recent Posts

Well this takes away the capability for the end user to select the article at his will emoticon Wish i could modify liferay source and pass layout id = 0 somehow. Right now within source, it dynamically sets layout id from themedisplay and hence this behavior.
Sagar A Vyas
RE: Embedding webcontent in Theme behavior
August 17, 2012 12:03 AM
Answer

Sagar A Vyas

Rank: Liferay Master

Posts: 657

Join Date: April 17, 2009

Recent Posts

Hmm I got your point, but what I am thinking is like footer is content which is not change frequently.

Well this takes away the capability for the end user to select the article at his will...


About this we have webcontent user can create or edit same anytime,only things is name(Web content) would be same.

Thanks,
Sagar Vyas