Combination View Flat View Tree View
Threads [ Previous | Next ]
Zoltan Gabriel
Portlets embedded in theme
May 6, 2008 7:58 AM
Answer

Zoltan Gabriel

Rank: New Member

Posts: 6

Join Date: April 28, 2008

Recent Posts

Hello!

I have been trying to add some portlets to my theme for a few days and I'm quite perplexed as to how it should work. The example that I have been using is the one found in the Jedi theme, namely the code that displays the award images.

One example is that I would like to put a jounal content article on each of my pages. By using the following code, I succeed in doing that:

$theme.runtime("56_INSTANCE_a123")

However if I try to set that the journal content should have no borders, nothing happens. The journal content will appear with a border. The code that I tried to use was the following:

$velocityPortletPreferences.setValue("portlet-setup-show-borders", "false")
$theme.runtime("56_INSTANCE_a123", "", $velocityPortletPreferences.toString())
$velocityPortletPreferences.reset()


Is this supported currently by Liferay? If yes, could you point me to place in the documentation where this is discussed?

There is another thing that is unclear to me. Firstly, using the $theme.runtime() method I display a portlet on my page without any customisation. Then I customise it as an administrator. And the thing I don't understand is that when I create a new page (set as a copy of the old one), the customisations are not copied to the new page and I have to set everything again. Despite that the instance Ids are the same for the portlets on the two pages. Is this supposed to work this way?

Thanks for any info.

Cheers.
Artur Linhart
RE: Portlets embedded in theme
May 6, 2008 12:14 PM
Answer

Artur Linhart

Rank: Expert

Posts: 458

Join Date: September 13, 2007

Recent Posts

Hello,

i have also spent some time with this till I got to the philosophy... But is is so, like You write - because the method runtime creates the new portlet in the current page. So, there is actually created a new record in the Db table having the portlet preferences for this page. Because every portlet can have different prefereces on every page, if You create the new page , the theme.runtime method just creates the new representation of the portlet on your new page - so it is also filled by the default settings.

It is also pretty problematic to change the article in the page to some another - because in the case You have already called the method theme.rutime for the first time, the portlet preferences are not stored - You must delete the portlet from the page and reinitialize it again. I make it in the following way:
 1
 2    #set ($locGroupAndArticleIdForChecking = "$locArticleGroupId" + "_" + "$locArticleId" + "_")
 3    $velocityPortletPreferences.setValue("portlet-setup-show-borders", "false")
 4    $velocityPortletPreferences.setValue("group-id", "$locArticleGroupId")
 5    $velocityPortletPreferences.setValue("article-id", "$locArticleId")
 6    #set ($locPortletId = "56_INSTANCE_" + $globCounterOfThemeDynamicPortletId)
 7    #set ($globCounterOfThemeDynamicPortletId = $globCounterOfThemeDynamicPortletId + 1)
 8    #set($locRenderedPortletContent = $theme.runtime($locPortletId, "", $velocityPortletPreferences.toString()))
 9    #set ($locCorrectArticleHasBeenReturned = $locRenderedPortletContent.contains($locGroupAndArticleIdForChecking))
10    #if ($locCorrectArticleHasBeenReturned)
11        ##correct - let it be
12    #else
13        ##incorrect - the article or group Id has been changed - so remove the old porltet preferences record and reinitialize it:
14        #set ($locPortletPreferenceService = $serviceLocator.findService("com.liferay.portal.service.PortletPreferencesLocalService"))
15        #set ($locPlidLong = $getterUtil.getLong($plid))
16        $locPortletPreferenceService.deletePortletPreferences(0, 3, $locPlidLong, $locPortletId)
17        ##  ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0 ... PortletKeys.PREFS_OWNER_ID_DEFAULT, 3 ... PortletKeys.PREFS_OWNER_TYPE_LAYOUT
18        #set ($locRenderedPortletContent = $theme.runtime($locPortletId, "", $velocityPortletPreferences.toString()))
19    #end
20    $locRenderedPortletContent
21    $velocityPortletPreferences.reset()


- in $locArticleGroupId and $locArticleId are the Ids of the group to which belongs the article and id of article I want to put ionto the theme and $globCounterOfThemeDynamicPortletId is the counter of the portlet to get always a unique Id of the portlet for the page (this is maybe not necessary). I use the fact the Id of the group and article assigned to $locGroupAndArticleIdForChecking is contained in the rendered portlet content of the rendered journal article content - so I first check if it is correct - this is in the case the article has not been changed to the article with another article id from the last time the page has been rendered. In the case the value from $locGroupAndArticleIdForChecking is not contained in the portlet content then the content previously pointed to some other article (with other article id), therefore I delete it by calling deletePortletPreferences and call the runtime method again to recreate the portlet content with the changed preferences.

It is necessary to the check for $locGroupAndArticleIdForChecking there, because otherwise to be sure the correct article is rendered, You would have always to delete the portelt preferences and create it again - this would be then the case with every rendering of every page - this would be very ineffective, so I added such a check there...

I hope this can help - if my description can be understood, what I am not very sure ;-)

with regards, Artur
Zoltan Gabriel
RE: Portlets embedded in theme
May 7, 2008 4:47 AM
Answer

Zoltan Gabriel

Rank: New Member

Posts: 6

Join Date: April 28, 2008

Recent Posts

Hello,

Your reply was absolutely understandable emoticon.

With the code you supplied I managed to set the article id and also remove the borders of the journal content portlet. This also solved the new page problem.
What didn't work for me though was the use of the global id counter. But the whole thing worked also without that.

So thank you, your comment was very helpful.

Cheers,
Zoltan
Artur Linhart
RE: Portlets embedded in theme
May 7, 2008 6:15 AM
Answer

Artur Linhart

Rank: Expert

Posts: 458

Join Date: September 13, 2007

Recent Posts

Ok, it's good to hear it could help You... :-)

I forgot to mention the globalId has to be set to the value which has 4 numbers, so tit has to be initialized first by calling, for example

1
2#set ($globCounterOfThemeDynamicPortletId = 1000)


- I used it because I created the more universal theme and there have been more sections where could be defined the articles - so in this case this would be a problem because the portlet Id would be not unique on one page... And because the sections are created dynamically I cannot assign to the dynamically generated portlets some predefined Ids, but they have to be computed automatically...
The part I copied here to You is the part of one velocity "procedure" which is called on multiple places from the main velocity file with different parameters - and then the global Id contains the global variable for the portlet id generation.

with regards, Archie.
Ray Augé
RE: Portlets embedded in theme
May 8, 2008 7:01 AM
Answer

Ray Augé

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1171

Join Date: February 7, 2005

Recent Posts

It'd be nice if PwdGenerator was in the velocity vars to make this more "standard", since that is the util we use internally to generate instance ids...
Artur Linhart
RE: Portlets embedded in theme
May 12, 2008 10:33 PM
Answer

Artur Linhart

Rank: Expert

Posts: 458

Join Date: September 13, 2007

Recent Posts

Aha, interesting inforamtion. Does it also assure the uniqueness of the Id?
I suppose it has to be unique at least in the page, isn't it?
Ray Augé
RE: Portlets embedded in theme
May 13, 2008 1:33 PM
Answer

Ray Augé

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1171

Join Date: February 7, 2005

Recent Posts

Well, consider the scope of the uniqueness includes the plid and the portletId. So, it's extremely small chance that two exact same id's are generated.

To be honest, I've never actually done any testing or looked closely at the validation code to see how hard we're checking to make sure there aren't collisions. Extracting the portlet instance ids from the page for only portlets of the same type would be necessary for the validation.
Matteo Pini
RE: Portlets embedded in theme
May 16, 2008 3:56 AM
Answer

Matteo Pini

Rank: New Member

Posts: 11

Join Date: March 3, 2008

Recent Posts

Artur, great code!!
Artur Linhart
RE: Portlets embedded in theme
May 19, 2008 1:45 AM
Answer

Artur Linhart

Rank: Expert

Posts: 458

Join Date: September 13, 2007

Recent Posts

thank You :-) nice to hear this can help somebody :-)

cheers, Archie
Ray Augé
Re: [Liferay Forums][4. Custom Theme Development] RE: Portlets embedded in
May 27, 2008 11:58 AM
Answer

Ray Augé

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1171

Join Date: February 7, 2005

Recent Posts

It'd be nice if PwdGenerator was in the velocity vars to make
this more "standard", since that is the util we use internally to
generate instance ids...


On Wed, 2008-05-07 at 13:15 +0000, Artur Linhart at Liferay's Community
Forums wrote:

> Ok, it's good to hear it could help You... :-)
>
> I forgot to mention the globalId has to be set to the value which has
> 4 numbers, so tit has to be initialized first by calling, for example
>
>
> 1
> 2#set ($globCounterOfThemeDynamicPortletId = 1000)
>
>
>
>
> - I used it because I created the more universal theme and there have
> been more sections where could be defined the articles - so in this
> case this would be a problem because the portlet Id would be not
> unique on one page... And because the sections are created dynamically
> I cannot assign to the dynamically generated portlets some predefined
> Ids, but they have to be computed automatically...
> The part I copied here to You is the part of one velocity "procedure"
> which is called on multiple places from the main velocity file with
> different parameters - and then the global Id contains the global
> variable for the portlet id generation.
>
> with regards, Archie.
> --
> Liferay Community Forum
> mb.239389.776959@events.liferay.com
> http://www.liferay.com/web/guest/community/forums/message_boards/message/776959

Raymond Augé
Software Engineer
Liferay, Inc.
Enterprise. Open Source. For Life.
Alan Stickler
RE: Portlets embedded in theme
December 16, 2009 12:52 PM
Answer

Alan Stickler

Rank: New Member

Posts: 2

Join Date: November 6, 2009

Recent Posts

Has anyone tested this for portlets deployed using plugins? I get a "This portlet has been undeployed" message for my custom portlet, but not for those defaulted in Liferay.
Alan Stickler
RE: Portlets embedded in theme
April 7, 2010 8:34 AM
Answer

Alan Stickler

Rank: New Member

Posts: 2

Join Date: November 6, 2009

Recent Posts

I was able to get this running by playing with the "instanceable" flag and explicitly setting the instance id in the vm.
anju K
RE: Portlets embedded in theme
April 13, 2010 7:30 AM
Answer

anju K

Rank: New Member

Posts: 6

Join Date: January 11, 2010

Recent Posts

Hi

Thanks for your suggestions.

I have created new theme successfully.. emoticon
Tarun S. Kayasth
RE: Portlets embedded in theme
April 13, 2009 6:44 AM
Answer

Tarun S. Kayasth

Rank: Regular Member

Posts: 159

Join Date: June 8, 2007

Recent Posts

I am trying to add alerts portlet in theme in Liferay 5.1.4 EE and it is giving javascript error with the use of following code:

$velocityPortletPreferences.setValue("portlet-setup-show-borders", "true")
$theme.runtime("83", "", $velocityPortletPreferences.toString())
$velocityPortletPreferences.reset()


Becuase of below errors portlet is not working properly.
Errors are as below:

Error: c.submit is not a function
Source File: http://localhost:8080/html/js/barebone.jsp?browserId=firefox&themeId=dsi_1_WAR_dsi_1theme&colorSchemeId=01&minifierType=js&minifierBundleId=javascript.barebone.files&minifierBundleDir=%2Fhtml%2Fjs&t=1239595987031
Line: 1


Error: c is undefined
Source File: http://localhost:8080/html/js/barebone.jsp?browserId=firefox&themeId=dsi_1_WAR_dsi_1theme&colorSchemeId=01&minifierType=js&minifierBundleId=javascript.barebone.files&minifierBundleDir=%2Fhtml%2Fjs&t=1239595987031
Line: 1


Can anyone help me to resolve this issue?

Thanks in advance,
Tarun
anju K
RE: Portlets embedded in theme
January 25, 2010 3:14 AM
Answer

anju K

Rank: New Member

Posts: 6

Join Date: January 11, 2010

Recent Posts

Hello Artur,

I saw your post regarind portley placement on theme.
Very nicely you have explained.

I am new to liferay and want to develop my own theme, i created a new theme in SDK env.
then i want to change banner, logo etc. the look and feel of theme, i want to change it programmatically.

Also i want to put 4 portlet on theme, so that it will be visible to the end user.

and i want to know in wihch file you have written the code below in your post, for visibilty of portlets in the theme.

please help me in these query, its very urgent.

Thanks in advance.
I will be waiting for your reply.

Anj
atul patel
RE: Portlets embedded in theme
January 28, 2010 12:36 AM
Answer

atul patel

Rank: Regular Member

Posts: 190

Join Date: November 17, 2006

Recent Posts

portal_normal.vm would be a good place to start.
Artur Linhart
RE: Portlets embedded in theme
February 9, 2010 11:54 PM
Answer

Artur Linhart

Rank: Expert

Posts: 458

Join Date: September 13, 2007

Recent Posts

Hello,

atul patel is right, it is efectivelly called from portal_normal.vm.

Because I have more such article sections in one article, I have put it into some separate script, which is then parametrized from outside and included more times in portal_normal.vm

Sorry for the delay, I was now for longer time busy with other things and had therefore no time to look here regulary...

with regards, Artur
Kristian Gil
RE: Portlets embedded in theme
August 9, 2010 4:35 PM
Answer

Kristian Gil

Rank: New Member

Posts: 22

Join Date: July 14, 2010

Recent Posts

Hello Artur,

First of all thanks for your code. I've been trying to solve an issue based on it. Actually, I have a question about it, how do you retrieve the articleId and the groupId?
I think I had succeeded retrieving the groupId with this code:

<%
ThemeDisplay themeDisplay= (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
long portletGroupId= themeDisplay.getPortletGroupId();
%>

But I don't know how I can retrieve the articleId. I don't know if maybe passing the article name in the references would work?

Thanks again!
Kristian
Artur Linhart
RE: Portlets embedded in theme
November 29, 2010 11:17 PM
Answer

Artur Linhart

Rank: Expert

Posts: 458

Join Date: September 13, 2007

Recent Posts

Hello, Kristian,

sorry for the delay, I have not been present here for some time and I did not receive the message about Your post...

The retrieve of the groupId and articleId is more complex stuff with some magic behind. But, shortly - we have build our own facility for parametrization of the theme through the "virtual pages" defined in the community (group) page structure.

First, we have defined the name of the root hidden page, under which we define the parameters, in our case the name was bckds_parameter_section. Then on the next level below this root were the definitions of the parameters we recognize and below every parameter definition then the parameter values. We then read the structure of such pages, filtered out the hidden root page by the reserved name and then resolved the parameter values from (as) the names of the subpages of the given community. It works, but is quite complex.

We have developed this under the version 5.1.2. At that time there was no possibility of the parametrization of the community, otherwise we would make it so. We have discussed this topic with Jorge Ferrer one year ago on the Liferay conference in Frankfurt/Offenbach and pleased him to append the possibility to define custom properties also for the communities. So, if it is so implemented in Liferay 6.0.x, what I hope, I would recommend to use the community properties to store such a informations like which article should be displayed there... The properties should be then accessible through service locator or corresponding service util class.

with regards, Artur

P.S. According to the groups - because the article id could be also from some other community (group), we developed such a parameter where we have stored the alternate Ids of the communities, where the articles shown below could be found and then the combined key has been resolved like this:
 1
 2#foreach ($locIterationGroupId in $bckds_theme_community_community_ids_for_article_search)
 3    #if ($CONST_UNDEFINED.equals($locArticleGroupId))
 4        #if ($journalArticleLocalService.hasArticle($locIterationGroupId, "$locArticleId"))
 5            #set ($locArticleGroupId = $locIterationGroupId)
 6        #end
 7    #end
 8#end
 9#if (!$CONST_UNDEFINED.equals($locArticleGroupId))
10    #set ($locGroupAndArticleIdForChecking = "$locArticleGroupId" + "_" + "$locArticleId" + "_")
11
12... etc. see my post with the source code above.
13                           
Kristian Gil
RE: Portlets embedded in theme
March 1, 2011 11:42 AM
Answer

Kristian Gil

Rank: New Member

Posts: 22

Join Date: July 14, 2010

Recent Posts

Thanks a lot Artur, really appreciate your help.
If not a problem I have another question. I'm trying to insert a Custom Portlet (non instanceable) but it only shows in 1 page and not in the rest of the pages.
I tried following similar codes as on this post but it's failing for some reason:

 1
 2#set($currentGroup = $layout.getGroup())
 3#set($locPortletGroupId = $currentGroup.getGroupId())
 4
 5#set ($locGroupAndArticleIdForChecking = $locPortletGroupId)
 6$velocityPortletPreferences.setValue("portlet-setup-show-borders", "false")
 7$velocityPortletPreferences.setValue("group-id", "$locPortletGroupId")
 8#set ($locPortletId = "1_WAR_stocksportlet")
 9#set ($locRenderedPortletContent = $theme.runtime($locPortletId, "", $velocityPortletPreferences.toString()))
10#set ($locCorrectPortletHasBeenReturned = $locRenderedPortletContent.contains($locGroupAndArticleIdForChecking))
11               
12#if ($locCorrectPortletHasBeenReturned)
13    ##correct - let it be
14#else
15    ##incorrect - the article or group Id has been changed - so remove the old porltet preferences record and reinitialize it:
16    #set ($locPortletPreferenceService =      $serviceLocator.findService("com.liferay.portal.service.PortletPreferencesLocalService"))
17        #set ($locPlidLong = $getterUtil.getLong($plid))
18        $locPortletPreferenceService.deletePortletPreferences(0, 3, $locPlidLong, $locPortletId)
19    ##  ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0 ... PortletKeys.PREFS_OWNER_ID_DEFAULT, 3 ... PortletKeys.PREFS_OWNER_TYPE_LAYOUT
20    #set ($locRenderedPortletContent = $theme.runtime($locPortletId, "", $velocityPortletPreferences.toString()))
21#end
22$locRenderedPortletContent
23$velocityPortletPreferences.reset()


Basically, I removed all the references to Article Id's and kept all the rest. Could there be something that I'm not considering?

Thanks a lot!
Artur Linhart
RE: Portlets embedded in theme
March 29, 2011 1:22 AM
Answer

Artur Linhart

Rank: Expert

Posts: 458

Join Date: September 13, 2007

Recent Posts

 1Hello, Kristian,
 2
 3sorry for the delay, but the notifications about the forum posts on liferay pages do not work for me, so I did not seen Your post till now.
 4
 5I think, the problem could be, You do not generate the portlet Id correctly. Other reason could be, the checking of "locGroupAndArticleIdForChecking" cannot be applied so like You do it, because the code I wrote was designed explicitely only for the article porltet and also uses the behavior of the article portlet generated code - in the case of other portlets this can look completely different.
 6
 7In every case I think, the usage of portlet Id is not correct - You use the code
 8
 9[code] #set ($locPortletId = "1_WAR_stocksportlet")


but like You can see, I use the portlet id (see above)

1#set ($locPortletId = "56_INSTANCE_" + $globCounterOfThemeDynamicPortletId)


- it was important - "56" is the Id of the installed portlet, then "INSTANCE" is necessary there and then the Id of the porrtlet which should consist from exactly 4 characters should be there. As far as I remember, it was important to keep this convention with the splitting of the information by the untderline character "_".

In the case of the non-instanceable portlet maybe this is not so exactly, I do not know... I propose You put the portlet to the page into normal area and then look into the DB table on the generated Id and use the same form for it - maybe it is different from the Id you used.

Then also the code connected with the checking is possibly not necessary - I made it, because the preferences of the portlet could change, because I have initiated the group and article Id from outside by some other mechanism - you should use here the code designed to the output generated by your stockportlet. And also the group id for the checking is from my point of view not enough "unique" to perform such a check. But maybe, You do not have to perform the checking at all...

Is the stock portlet dependent on the group Id? Is the group Id written to the portlet preferences like "group-id"? if no, then this checking mechanism (code with "#if ($locCorrectPortletHasBeenReturned) ... #else ... #end) should not be there I think...
Nick Straguzzi
RE: Portlets embedded in theme
February 5, 2012 9:51 PM
Answer

Nick Straguzzi

Rank: New Member

Posts: 20

Join Date: April 29, 2011

Recent Posts

Artur, thanks for your explanation. I've updated the Wiki page to include your suggestion on how to change Portlet preferences, which seems to be a very common problem among developers. Please have a look at it and ensure that it's correct. I've tested the macro at the end of the page, and it works beautifully on my machine anyway.

http://www.liferay.com/community/wiki/-/wiki/1071674/Embedding+a+portlet+in+the+theme/maximized

Regards,
Nick
Artur Linhart
RE: Portlets embedded in theme
February 7, 2012 5:17 AM
Answer

Artur Linhart

Rank: Expert

Posts: 458

Join Date: September 13, 2007

Recent Posts

Hello,

I have no possibility to test it exactly now, but your macro seems to be a nice generalization of my original code, thank you :-)
Mazhar Alam
RE: Portlets embedded in theme
February 7, 2012 5:53 AM
Answer

Mazhar Alam

Rank: Regular Member

Posts: 188

Join Date: November 25, 2011

Recent Posts

Hi Artur,

I need to include the view.jsp of a portlet inside a theme portal_normal.vm file.How do i do it..

Thanks in advance

Regards,
Mazhar Alam
Artur Linhart
RE: Portlets embedded in theme
February 7, 2012 6:20 AM
Answer

Artur Linhart

Rank: Expert

Posts: 458

Join Date: September 13, 2007

Recent Posts

Hello,

OK, this is not exactly for this thread, but... :-) I never used this technique, but, as I have found on http://maryniuk.blogspot.com/2009/12/liferay-include-jsp-into-velocity.html it seems to be possible to do it in this way:

To add some JSP page into your theme, simply do like this:

1$theme.include($themeServletContext, "/elements.jsp")


This example assumes that you have a file, called "elements.jsp" and it is located in the root of your theme (i.e. accessible from the URL like "http://yourhost/your-theme-name/elements.jsp").
Mazhar Alam
RE: Portlets embedded in theme
February 7, 2012 6:42 AM
Answer

Mazhar Alam

Rank: Regular Member

Posts: 188

Join Date: November 25, 2011

Recent Posts

Thanks Artur, But i need to include portlets jsp into the theme. You gave me the solution that includes jsp which is located in theme.
But i need to include portlets view.jsp in theme.? How do i do it.?

Thanks in advance

Regards,
Mazhar
David H Nebinger
RE: Portlets embedded in theme
February 7, 2012 7:40 AM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 8378

Join Date: September 1, 2006

Recent Posts

A portlet's JSP will probably not work outside of the portlet context. A portlet is more than just it's jsp pages...
Mazhar Alam
RE: Portlets embedded in theme
February 10, 2012 11:51 PM
Answer

Mazhar Alam

Rank: Regular Member

Posts: 188

Join Date: November 25, 2011

Recent Posts

Thanks..got it...
Pablo Raguenes
RE: Portlets embedded in theme
November 30, 2010 1:45 AM
Answer

Pablo Raguenes

Rank: Junior Member

Posts: 62

Join Date: November 18, 2010

Recent Posts

Artur Linhart:
Hello,

i have also spent some time with this till I got to the philosophy... But is is so, like You write - because the method runtime creates the new portlet in the current page. So, there is actually created a new record in the Db table having the portlet preferences for this page. Because every portlet can have different prefereces on every page, if You create the new page , the theme.runtime method just creates the new representation of the portlet on your new page - so it is also filled by the default settings.

It is also pretty problematic to change the article in the page to some another - because in the case You have already called the method theme.rutime for the first time, the portlet preferences are not stored - You must delete the portlet from the page and reinitialize it again. I make it in the following way:
 1
 2    #set ($locGroupAndArticleIdForChecking = "$locArticleGroupId" + "_" + "$locArticleId" + "_")
 3    $velocityPortletPreferences.setValue("portlet-setup-show-borders", "false")
 4    $velocityPortletPreferences.setValue("group-id", "$locArticleGroupId")
 5    $velocityPortletPreferences.setValue("article-id", "$locArticleId")
 6    #set ($locPortletId = "56_INSTANCE_" + $globCounterOfThemeDynamicPortletId)
 7    #set ($globCounterOfThemeDynamicPortletId = $globCounterOfThemeDynamicPortletId + 1)
 8    #set($locRenderedPortletContent = $theme.runtime($locPortletId, "", $velocityPortletPreferences.toString()))
 9    #set ($locCorrectArticleHasBeenReturned = $locRenderedPortletContent.contains($locGroupAndArticleIdForChecking))
10    #if ($locCorrectArticleHasBeenReturned)
11        ##correct - let it be
12    #else
13        ##incorrect - the article or group Id has been changed - so remove the old porltet preferences record and reinitialize it:
14        #set ($locPortletPreferenceService = $serviceLocator.findService("com.liferay.portal.service.PortletPreferencesLocalService"))
15        #set ($locPlidLong = $getterUtil.getLong($plid))
16        $locPortletPreferenceService.deletePortletPreferences(0, 3, $locPlidLong, $locPortletId)
17        ##  ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0 ... PortletKeys.PREFS_OWNER_ID_DEFAULT, 3 ... PortletKeys.PREFS_OWNER_TYPE_LAYOUT
18        #set ($locRenderedPortletContent = $theme.runtime($locPortletId, "", $velocityPortletPreferences.toString()))
19    #end
20    $locRenderedPortletContent
21    $velocityPortletPreferences.reset()


- in $locArticleGroupId and $locArticleId are the Ids of the group to which belongs the article and id of article I want to put ionto the theme and $globCounterOfThemeDynamicPortletId is the counter of the portlet to get always a unique Id of the portlet for the page (this is maybe not necessary). I use the fact the Id of the group and article assigned to $locGroupAndArticleIdForChecking is contained in the rendered portlet content of the rendered journal article content - so I first check if it is correct - this is in the case the article has not been changed to the article with another article id from the last time the page has been rendered. In the case the value from $locGroupAndArticleIdForChecking is not contained in the portlet content then the content previously pointed to some other article (with other article id), therefore I delete it by calling deletePortletPreferences and call the runtime method again to recreate the portlet content with the changed preferences.

It is necessary to the check for $locGroupAndArticleIdForChecking there, because otherwise to be sure the correct article is rendered, You would have always to delete the portelt preferences and create it again - this would be then the case with every rendering of every page - this would be very ineffective, so I added such a check there...

I hope this can help - if my description can be understood, what I am not very sure ;-)

with regards, Artur


Hello Artur and thanks for you post emoticon

I'm gonna try to see if it works (more if I can make it work) but I found the solution quite "heavy" (creating/deleting portlets instances).
Since your solution is quite "old" (more than 2 years in computer science is prehistoric emoticon ), have you found another one since then ?
I'd like to use properties like "preferences-company-wide=true", I think they could do the trick to create a unique instance of the portlet displayed on multiple pages
The problem is that I don't see where I can put these properties emoticon
I'm not dealing with a custom portlet, but the plain Web Content Display portlet provided by Liferay, so how can I customize "my" portlet (a specific instance of Web Content Display portlet) ?

If anyone could bring some advice, it would be much appreciated

Regards
Artur Linhart
RE: Portlets embedded in theme
December 1, 2010 6:35 AM
Answer

Artur Linhart

Rank: Expert

Posts: 458

Join Date: September 13, 2007

Recent Posts

Hello, Pablo,

I have used the standard Web Content Portlet, so no vustom specific porltet. By the code
1
2 $velocityPortletPreferences.setValue("portlet-setup-show-borders", "false")
3 $velocityPortletPreferences.setValue("group-id", "$locArticleGroupId")
4 $velocityPortletPreferences.setValue("article-id", "$locArticleId")


you set the preferences of the Web Content Portlet and by

1
2#set ($locPortletId = "56_INSTANCE_" + $globCounterOfThemeDynamicPortletId)


Your define, there has to be used the porltet Web Content Portlet - see for example the portlet-custom.xml, there is defined the Id 56 has (or at least in the version 5.1.x and 5.2.x have had) the Web content portlet:
 1
 2    <portlet>
 3        <portlet-name>56</portlet-name>
 4        <display-name>Journal Content</display-name>
 5        <portlet-class>com.liferay.portlet.StrutsPortlet</portlet-class>
 6        <init-param>
 7            <name>view-action</name>
 8            <value>/journal_content/view</value>
 9        </init-param>
10        <expiration-cache>0</expiration-cache>
11        <supports>
12            <mime-type>text/html</mime-type>
13        </supports>
14        <supports>
15            <mime-type>application/vnd.wap.xhtml+xml</mime-type>
16        </supports>
17        <resource-bundle>com.liferay.portlet.StrutsResourceBundle</resource-bundle>
18        <security-role-ref>
19            <role-name>guest</role-name>
20        </security-role-ref>
21        <security-role-ref>
22            <role-name>power-user</role-name>
23        </security-role-ref>
24        <security-role-ref>
25            <role-name>user</role-name>
26        </security-role-ref>
27    </portlet>


At last, by the statement

1
2 #set ($locRenderedPortletContent = $theme.runtime($locPortletId, "", $velocityPortletPreferences.toString()))


will be added a new occurence of the Web Content Portlet to the correspoénding theme-area and that is it. I did not tested it under 6.0.x but think it could work there still...

(
Pablo Raguenes
RE: Portlets embedded in theme
December 1, 2010 7:49 AM
Answer

Pablo Raguenes

Rank: Junior Member

Posts: 62

Join Date: November 18, 2010

Recent Posts

Thanks again for your answer emoticon

I'll try to explain my problem (or what's left of my problem)

I have a web content portlet in some administration page that is supposed to represent the footer of all the pages on the portal. The goal is that anybody (with the appropriate rights) could change what appears in the footer (add/remove links, images, all the things the web content portlet allows) without having to know computer programming.
This "footer administration" portlet has a specific CSS class applied to it, that way the footer still gets the same style as the rest of the theme.

I've managed to "copy" an instance of this "footer administration" portlet (thanks to your post) on every pages using the $theme.runtime() method. I've also managed to apply the correct style to the duplicated portlets.

My problem is that my IDs are hard-coded (shame on me emoticon), I think I know how I could retrieve the "group-id" from the $theme variable. But if someone changes the content of the footer administration portlet, changes are not passed to the duplicated portlets.
So I need to know which article (article ID) is displayed in the footer administration portlet, so my duplicated portlets point to the same article.

I think doing all that is possible, it's just I find it quite heavy (to code and thus to execute). It's a pity there's no simple way to just display an instance of a portlet with the same configuration, style, content, etc... and that we have to create/delete portlet instances to have the same result emoticon
Palani Venkat
Move Portal changes from dev machine to Production machine
December 1, 2010 8:50 AM
Answer

Palani Venkat

Rank: Junior Member

Posts: 32

Join Date: November 10, 2010

Recent Posts

Hi,

Could you please help me out for the below requirement , its urgent, its urgent?

how to move all the pages and its content to the new environment.

My requirement is as below.

Currently we are working in development machine and we have installed liferay portal in production machine, so now the production machine has only fresh liferay

portal setup.

Now i want to move all the changes whatever we have done in development machine like creation of organization, user creation, page creation to production

machine in one time.


I have created LAR file in development machine portal and import it in production machine liferay portal, in this i have to create LAR file for each and every page but

i want the whole changes in one time.

Could you pls help me in giving the solution for this?

Thanks in advance for your suggestion.

Regards,
Palani
Artur Linhart
RE: Move Portal changes from dev machine to Production machine
December 1, 2010 9:01 AM
Answer

Artur Linhart

Rank: Expert

Posts: 458

Join Date: September 13, 2007

Recent Posts

Please, open the new thread for this issue, it does not belong here.

From my point of view, if You have the development machine completely so, like the productive should be with all the data, then I would rather explicitely copy the database content from one schema to another (and, possibly if You use file-based document library also compelte content of it) and the configuration files.

I have not very good experiences with LAR export/import. Especially there were problems with permissions which were not exported or imported again. I do not know how is it now if everything is fixed, but without a deep tests I would not use LAR export import for such a complete export and import of all data of portal.
Pablo Raguenes
RE: Move Portal changes from dev machine to Production machine
December 1, 2010 9:10 AM
Answer

Pablo Raguenes

Rank: Junior Member

Posts: 62

Join Date: November 18, 2010

Recent Posts

Palani Venkat:
Hi,

Could you please help me out for the below requirement , its urgent, its urgent?

how to move all the pages and its content to the new environment.

My requirement is as below.

Currently we are working in development machine and we have installed liferay portal in production machine, so now the production machine has only fresh liferay

portal setup.

Now i want to move all the changes whatever we have done in development machine like creation of organization, user creation, page creation to production

machine in one time.


I have created LAR file in development machine portal and import it in production machine liferay portal, in this i have to create LAR file for each and every page but

i want the whole changes in one time.

Could you pls help me in giving the solution for this?

Thanks in advance for your suggestion.

Regards,
Palani


Hi Palani emoticon

I understand you can get quite panicked during release stage, but you should not :
- make multiple posts about the same problem (http://www.liferay.com/community/forums/-/message_boards/message/6666992)
- post in a thread not related to it
- post in the wrong section

It will only unleash the wrath of moderators emoticon
I'll give you some clues in the other thread emoticon
Artur Linhart
RE: Portlets embedded in theme
December 1, 2010 8:57 AM
Answer

Artur Linhart

Rank: Expert

Posts: 458

Join Date: September 13, 2007

Recent Posts

It is strange. is it really so, somebody is changing the content of the approved non-expired portlet without increasing the version of it and the change will be not shown below?

Do You use staging?
Pablo Raguenes
RE: Portlets embedded in theme
December 1, 2010 9:40 AM
Answer

Pablo Raguenes

Rank: Junior Member

Posts: 62

Join Date: November 18, 2010

Recent Posts

Artur Linhart:
It is strange. is it really so, somebody is changing the content of the approved non-expired portlet without increasing the version of it and the change will be not shown below?

Do You use staging?

I don't know about staging emoticon
I'm still not used to the CMS part, I've only deployed Liferay and created a theme. To me, Web Content was just a portlet in which I could write "web content", it's only recently I discovered the notion of article, version, etc... and I'm still not fully clear on it emoticon
Artur Linhart
RE: Portlets embedded in theme
December 2, 2010 2:05 AM
Answer

Artur Linhart

Rank: Expert

Posts: 458

Join Date: September 13, 2007

Recent Posts

how do You edit Your article shown in the theme, if the content of the article displayed in the theme stays unchanged?
satish M
RE: Portlets embedded in theme
December 2, 2010 2:13 AM
Answer

satish M

Rank: New Member

Posts: 23

Join Date: November 30, 2010

Recent Posts

sorry i am not understand.
can you explain what is the IDE forLiferay 5.1.2 IDE and how to cinfigure..
Pablo Raguenes
RE: Portlets embedded in theme
December 2, 2010 2:32 AM
Answer

Pablo Raguenes

Rank: Junior Member

Posts: 62

Join Date: November 18, 2010

Recent Posts

Artur Linhart:
how do You edit Your article shown in the theme, if the content of the article displayed in the theme stays unchanged?

OK, I think I get my mistake, I was editing using the "Add Web Content" icon emoticon instead of the "Edit Web Content", my bad emoticon
I think I'm gonna spend the rest of the day learning how to use this key portlet
Artur Linhart
RE: Portlets embedded in theme
December 2, 2010 2:06 PM
Answer

Artur Linhart

Rank: Expert

Posts: 458

Join Date: September 13, 2007

Recent Posts

I think You should not edit the article directly. Normally the web content portlet should not be changeable by the users. I would suggest to give some users access to the cms administration and to let them edit the concrete article. You only must know which article is it which You edit and thats it. You can also put this article into web content portlet (in the configuration you can select existing article) to some special "theme administration" page which You create and then if somebody edits the content here and saves it, then also the theme-embedded article will be changed
Pablo Raguenes
RE: Portlets embedded in theme
December 3, 2010 12:38 AM
Answer

Pablo Raguenes

Rank: Junior Member

Posts: 62

Join Date: November 18, 2010

Recent Posts

Artur Linhart:
I think You should not edit the article directly. Normally the web content portlet should not be changeable by the users. I would suggest to give some users access to the cms administration and to let them edit the concrete article. You only must know which article is it which You edit and thats it. You can also put this article into web content portlet (in the configuration you can select existing article) to some special "theme administration" page which You create and then if somebody edits the content here and saves it, then also the theme-embedded article will be changed

It's that second solution I opted for, I've added a Web Content portlet in an administration page, the only problem is that I was creating a new article instead of editing the current one. I've read the documentation about Web Content Management (http://www.liferay.com/documentation/liferay-portal/6.0/administration/-/ai/building-a-site-with-liferay-s-wcm) and now it's more clear
I'll try to find a way to forbid people to change the article in this portlet, but only editing the existent

Thanks again for your help emoticon
Artur Linhart
RE: Portlets embedded in theme
December 6, 2010 2:17 PM
Answer

Artur Linhart

Rank: Expert

Posts: 458

Join Date: September 13, 2007

Recent Posts

OK, glad to help You :-)
Pablo Raguenes
RE: Portlets embedded in theme
December 7, 2010 6:12 AM
Answer

Pablo Raguenes

Rank: Junior Member

Posts: 62

Join Date: November 18, 2010

Recent Posts

OK, finally after learning how to use the Web Content portlet, it seems like I wasn't making any mistake, it's just a bug with Liferay and Firefox emoticon

http://issues.liferay.com/browse/LPS-12723

I wasn't adding new content, I was trying to edit it, but the previous content wasn't shown in the editor (in Firefox). So I'll just use Chromium in the meantime emoticon
Palani Venkat
RE: Portlets embedded in theme
December 1, 2010 9:06 PM
Answer

Palani Venkat

Rank: Junior Member

Posts: 32

Join Date: November 10, 2010

Recent Posts

Sorry Artur and Pablo.. i will open new thread for this and why i am added here is that its urgent thats why and again sorry for the mistake... and thanks for your time..
satish M
RE: Portlets embedded in theme
December 1, 2010 9:20 PM
Answer

satish M

Rank: New Member

Posts: 23

Join Date: November 30, 2010

Recent Posts

Hi Athur,

I am new to liferay. I have created the account in liferay just one day before.
Sorry i am replying to one of your post instead of creating the new post.
Actually i don't know how to create the new post.
My problem is I am using the liferay-plugins-sdk-5.1.2 and liferay-portal-tomcat-5.5-5.1.2.
I have installed these two in my meshine.
But i need to develop the portlets in IDE. Which ide is suitable for this requirement.
And how to configure it.
Please help me for my queries.

Thanks,
Satish.
gofri _
RE: Portlets embedded in theme
December 8, 2010 7:34 AM
Answer

gofri _

Rank: Junior Member

Posts: 92

Join Date: March 2, 2007

Recent Posts

Hello,
Using Artur's solution to add Web Content in vm template almost works (with a little fix for Liferay 6 - by default displays content 2 times).
I want to ask if there is some movement in that area in Liferay? Isn't there a more convenient way to clone Web Article in many pages?
10x in advance.
Artur Linhart
RE: Portlets embedded in theme
December 8, 2010 7:47 AM
Answer

Artur Linhart

Rank: Expert

Posts: 458

Join Date: September 13, 2007

Recent Posts

Interesting, what has to be fixed? I am still waiting for 6.1 to go deeper into the tests, so I did not test our approach in 6.x till now...

Thanks in advance for any information.
gofri _
RE: Portlets embedded in theme
December 8, 2010 8:18 AM
Answer

gofri _

Rank: Junior Member

Posts: 92

Join Date: March 2, 2007

Recent Posts

I am not very sure, but from what I see Web Content is rendered on every $theme.runtime call (even in evaluations) = total 2 times. But I don't want to mislead someone - I'm still testing it.
Sean R
RE: Portlets embedded in theme
January 8, 2011 9:43 PM
Answer

Sean R

Rank: New Member

Posts: 1

Join Date: January 8, 2011

Recent Posts

Thanks Artur and others who have contributed to this thread. It has been helpful in providing me insight on embedded instanceable portlets.

I was experiencing the same issue as gofri _. theme.runtime was rending HTML instead of being set to the variable locRenderedPortletContent. (I am using Liferay CE 6.0.5 on JBoss EAP 4.3 so it seems likely this is due to a change in Liferay 6.x.)

The issue seems to be caused by lines where the set directive contains references inside of references. For example in the following line:
1#set($locRenderedPortletContent = $theme.runtime($locPortletId, "", $velocityPortletPreferences.toString()))


I was able to get it working by using the define directive instead of set directive on lines containing the embedded references. The following is what works for me:

 1
 2#set ($globCounterOfThemeDynamicPortletId = 1000)
 3#set ($locArticleId = <insert article number>)
 4#set ($locArticleGroupId = <insert group id>)
 5#set ($locGroupAndArticleIdForChecking = "$locArticleGroupId" + "_" + "$locArticleId" + "_")
 6$velocityPortletPreferences.setValue("portlet-setup-show-borders", "false")
 7$velocityPortletPreferences.setValue("group-id", "$locArticleGroupId")
 8$velocityPortletPreferences.setValue("article-id", "$locArticleId")
 9#set ($locPortletId = "56_INSTANCE_" + $globCounterOfThemeDynamicPortletId)
10#set ($globCounterOfThemeDynamicPortletId = $globCounterOfThemeDynamicPortletId + 1)
11#define($locRenderedPortletContent)$theme.runtime($locPortletId, "", $velocityPortletPreferences.toString())#end
12#define($locCorrectArticleHasBeenReturned)$locRenderedPortletContent.contains($locGroupAndArticleIdForChecking)#end
13#if ($locCorrectArticleHasBeenReturned)
14    ##correct - let it be
15#else
16    ##incorrect - the article or group Id has been changed - so remove the old porltet preferences record and reinitialize it:
17    #set ($locPortletPreferenceService = $serviceLocator.findService("com.liferay.portal.service.PortletPreferencesLocalService"))
18    #set ($locPlidLong = $getterUtil.getLong($plid))
19    $locPortletPreferenceService.deletePortletPreferences(0, 3, $locPlidLong, $locPortletId)
20    ##  ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0 ... PortletKeys.PREFS_OWNER_ID_DEFAULT, 3 ... PortletKeys.PREFS_OWNER_TYPE_LAYOUT
21    #define($locRenderedPortletContent)$theme.runtime($locPortletId, "", $velocityPortletPreferences.toString())#end
22#end
23$locRenderedPortletContent
24$velocityPortletPreferences.reset()
gofri _
RE: Portlets embedded in theme
January 9, 2011 8:54 AM
Answer

gofri _

Rank: Junior Member

Posts: 92

Join Date: March 2, 2007

Recent Posts

I choose another solution at the end:
1
2   #set ($locArticleId = 10111)
3   #set ($locArticleGroupId = 10222)
4            
5   #set ($script_and_style_includes =    $journalContentUtil.getContent($getterUtil.getLong("$locArticleGroupId"), "$locArticleId", "", "view", "en", $themeDisplay))
6   
7   $script_and_style_includes


This doesn't create a row in a portletPreferences table and looks more flexible.
Artur Linhart
RE: Portlets embedded in theme
January 12, 2011 9:46 PM
Answer

Artur Linhart

Rank: Expert

Posts: 458

Join Date: September 13, 2007

Recent Posts

Well, it looks interesting, thank You :-)
Pablo Raguenes
RE: Portlets embedded in theme
February 1, 2011 7:56 AM
Answer

Pablo Raguenes

Rank: Junior Member

Posts: 62

Join Date: November 18, 2010

Recent Posts

gofri _:
I choose another solution at the end:
1
2   #set ($locArticleId = 10111)
3   #set ($locArticleGroupId = 10222)
4            
5   #set ($script_and_style_includes =    $journalContentUtil.getContent($getterUtil.getLong("$locArticleGroupId"), "$locArticleId", "", "view", "en", $themeDisplay))
6   
7   $script_and_style_includes


This doesn't create a row in a portletPreferences table and looks more flexible.

Thanks a lot ! That's exactly what I've been looking for emoticon
Nikos Kapatos
RE: Portlets embedded in theme
May 22, 2009 4:09 AM
Answer

Nikos Kapatos

Rank: Junior Member

Posts: 57

Join Date: November 11, 2008

Recent Posts

Artur Linhart:

 1
 2    #set ($locGroupAndArticleIdForChecking = "$locArticleGroupId" + "_" + "$locArticleId" + "_")
 3    $velocityPortletPreferences.setValue("portlet-setup-show-borders", "false")
 4    $velocityPortletPreferences.setValue("group-id", "$locArticleGroupId")
 5    $velocityPortletPreferences.setValue("article-id", "$locArticleId")
 6    #set ($locPortletId = "56_INSTANCE_" + $globCounterOfThemeDynamicPortletId)
 7    #set ($globCounterOfThemeDynamicPortletId = $globCounterOfThemeDynamicPortletId + 1)
 8    #set($locRenderedPortletContent = $theme.runtime($locPortletId, "", $velocityPortletPreferences.toString()))
 9    #set ($locCorrectArticleHasBeenReturned = $locRenderedPortletContent.contains($locGroupAndArticleIdForChecking))
10    #if ($locCorrectArticleHasBeenReturned)
11        ##correct - let it be
12    #else
13        ##incorrect - the article or group Id has been changed - so remove the old porltet preferences record and reinitialize it:
14        #set ($locPortletPreferenceService = $serviceLocator.findService("com.liferay.portal.service.PortletPreferencesLocalService"))
15        #set ($locPlidLong = $getterUtil.getLong($plid))
16        $locPortletPreferenceService.deletePortletPreferences(0, 3, $locPlidLong, $locPortletId)
17        ##  ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0 ... PortletKeys.PREFS_OWNER_ID_DEFAULT, 3 ... PortletKeys.PREFS_OWNER_TYPE_LAYOUT
18        #set ($locRenderedPortletContent = $theme.runtime($locPortletId, "", $velocityPortletPreferences.toString()))
19    #end
20    $locRenderedPortletContent
21    $velocityPortletPreferences.reset()




Is it possible to have another example of this code in a simpler version? Like for the language or the search

I tried to change the code here but my skills on coding r not that good.

If anyone can provide an example it will be great.

Thanx

Edit: I tried to make it work for the search portlet but Instead of the search box I got this msg in the portlet on the page "
This portlet has been undeployed. Please redeploy it or remove it from the page. "

Can someone help?

------------------------------

EDIT 2:

Ok I managed to correct the previous problem but now I get the portlet 2 times in the page + "You do not have the roles required to access this portlet." alert.

In the log i got 2 warning

WARN [PortletRequestProcessor:471] The struts path language does not belong to portlet 82_INSTANCE_1000. Check the definition in liferay-portlet.xml

WARN [PortletRequestProcessor:507]

Please if anyone can help.

P.S. Where I can find a list of with all these variables, objects, methods etc? I followed some links but instead of helping it get more confusing that it is now and I still do not have a clear list.

For example the "$locRenderedPortletContent.contains". Is there something else?
Like $locRenderedPortletContent.notContains or $locRenderedPortletContent.head or something

Is this a variable that already exists? If yes where r the others?
Artur Linhart
RE: Portlets embedded in theme
April 26, 2010 1:35 AM
Answer

Artur Linhart

Rank: Expert

Posts: 458

Join Date: September 13, 2007

Recent Posts

Hi, Nikos,

sorry, I missed Your post... Possibly it is no longer important for You, but just shortly:

1. Do You still have the problem with the language portlet?

2. The given rendered content in the variable $locRenderedPortletContent is just the java string, the method contains is described for example [url=http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html#contains(java.lang.CharSequence)]here. The same page contains also other possible methods You can use with the String, but I think, You know it :-).

with best regards, Artur
Nikos Kapatos
RE: Portlets embedded in theme
May 22, 2009 4:13 AM
Answer

Nikos Kapatos

Rank: Junior Member

Posts: 57

Join Date: November 11, 2008

Recent Posts

BUMP
Nikos Kapatos
RE: Portlets embedded in theme
May 25, 2009 5:34 AM
Answer

Nikos Kapatos

Rank: Junior Member

Posts: 57

Join Date: November 11, 2008

Recent Posts

BUMP

6k views and noone can help?
atul patel
RE: Portlets embedded in theme
May 25, 2009 10:14 AM
Answer

atul patel

Rank: Regular Member

Posts: 190

Join Date: November 17, 2006

Recent Posts

It always bothered me that a new database record would need to be created per page when using the $theme.runtime method of injecting a portlet.

Have you considered the following approach. Create a hidden page with your portlet on it. Then copy the "Sharing" javascipt injection code into your theme.

I haven't tried it, but it seems like it would work to me.

If you try it and it works, please let me know.

emoticon
Nicolas Chambrier
RE: Portlets embedded in theme
July 21, 2009 10:11 AM
Answer

Nicolas Chambrier

Rank: New Member

Posts: 9

Join Date: July 1, 2009

Recent Posts

This awful JS generates an iframe... This is hardly usable even to share with external websites, so I can't imagine using this for internal pages...
Giuseppe Calignano
RE: Portlets embedded in theme
November 18, 2009 6:30 AM
Answer

Giuseppe Calignano

Rank: New Member

Posts: 3

Join Date: March 11, 2009

Recent Posts

Artur Linhart:
 1
 2    #set ($locGroupAndArticleIdForChecking = "$locArticleGroupId" + "_" + "$locArticleId" + "_")
 3    $velocityPortletPreferences.setValue("portlet-setup-show-borders", "false")
 4    $velocityPortletPreferences.setValue("group-id", "$locArticleGroupId")
 5    $velocityPortletPreferences.setValue("article-id", "$locArticleId")
 6    #set ($locPortletId = "56_INSTANCE_" + $globCounterOfThemeDynamicPortletId)
 7    #set ($globCounterOfThemeDynamicPortletId = $globCounterOfThemeDynamicPortletId + 1)
 8    #set($locRenderedPortletContent = $theme.runtime($locPortletId, "", $velocityPortletPreferences.toString()))
 9    #set ($locCorrectArticleHasBeenReturned = $locRenderedPortletContent.contains($locGroupAndArticleIdForChecking))
10    #if ($locCorrectArticleHasBeenReturned)
11        ##correct - let it be
12    #else
13        ##incorrect - the article or group Id has been changed - so remove the old porltet preferences record and reinitialize it:
14        #set ($locPortletPreferenceService = $serviceLocator.findService("com.liferay.portal.service.PortletPreferencesLocalService"))
15        #set ($locPlidLong = $getterUtil.getLong($plid))
16        $locPortletPreferenceService.deletePortletPreferences(0, 3, $locPlidLong, $locPortletId)
17        ##  ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0 ... PortletKeys.PREFS_OWNER_ID_DEFAULT, 3 ... PortletKeys.PREFS_OWNER_TYPE_LAYOUT
18        #set ($locRenderedPortletContent = $theme.runtime($locPortletId, "", $velocityPortletPreferences.toString()))
19    #end
20    $locRenderedPortletContent
21    $velocityPortletPreferences.reset()


Hi guys,

can you tell me if that code works with liferay 5.2.2?

thanks and regards:
Artur Linhart
RE: Portlets embedded in theme
November 29, 2010 11:19 PM
Answer

Artur Linhart

Rank: Expert

Posts: 458

Join Date: September 13, 2007

Recent Posts

Hello,

I would guess this code should work in 5.2.2 too. The basic internal page management did not change as far as I know...

regards, Artur
Pieter Haro
RE: Portlets embedded in theme
April 9, 2012 1:33 AM
Answer

Pieter Haro

Rank: New Member

Posts: 8

Join Date: July 18, 2011

Recent Posts

Hi,

I've configured inter portlet communication between two portlets and everything is working fine except when I try to embed a portlet in the theme with: $theme.runtime(). The portlet is shown without any problems, but isn't receiving any events that are broadcasted by the portal.

do you know how to get around this problem?
delang j
RE: Portlets embedded in theme
May 9, 2012 5:44 PM
Answer

delang j

Rank: Regular Member

Posts: 223

Join Date: July 13, 2008

Recent Posts

1$velocityPortletPreferences.setValue("portletSetupShowBorders", "false")
2$velocityPortletPreferences.setValue("groupId", "10180")
3$velocityPortletPreferences.setValue("articleId", "28181")
4$theme.runtime("56_INSTANCE_4mNaGhju9vqh", "", $velocityPortletPreferences.toString())
5$velocityPortletPreferences.reset()


working perfectly in my LR 6.1 in .tpl file. emoticon