Foros de discusión

Portlets embedded in theme

Zoltan Gabriel, modificado hace 15 años.

Portlets embedded in theme

New Member Mensajes: 6 Fecha de incorporación: 29/04/08 Mensajes recientes
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.
thumbnail
Artur Linhart, modificado hace 15 años.

RE: Portlets embedded in theme

Expert Mensajes: 459 Fecha de incorporación: 13/09/07 Mensajes recientes
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:

	#set ($locGroupAndArticleIdForChecking = "$locArticleGroupId" + "_" + "$locArticleId" + "_")
	$velocityPortletPreferences.setValue("portlet-setup-show-borders", "false")
	$velocityPortletPreferences.setValue("group-id", "$locArticleGroupId")
	$velocityPortletPreferences.setValue("article-id", "$locArticleId")
	#set ($locPortletId = "56_INSTANCE_" + $globCounterOfThemeDynamicPortletId)
	#set ($globCounterOfThemeDynamicPortletId = $globCounterOfThemeDynamicPortletId + 1)
	#set($locRenderedPortletContent = $theme.runtime($locPortletId, "", $velocityPortletPreferences.toString()))
	#set ($locCorrectArticleHasBeenReturned = $locRenderedPortletContent.contains($locGroupAndArticleIdForChecking))
	#if ($locCorrectArticleHasBeenReturned)
		##correct - let it be
	#else
		##incorrect - the article or group Id has been changed - so remove the old porltet preferences record and reinitialize it:
		#set ($locPortletPreferenceService = $serviceLocator.findService("com.liferay.portal.service.PortletPreferencesLocalService"))
		#set ($locPlidLong = $getterUtil.getLong($plid))
		$locPortletPreferenceService.deletePortletPreferences(0, 3, $locPlidLong, $locPortletId)
		##  ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0 ... PortletKeys.PREFS_OWNER_ID_DEFAULT, 3 ... PortletKeys.PREFS_OWNER_TYPE_LAYOUT
		#set ($locRenderedPortletContent = $theme.runtime($locPortletId, "", $velocityPortletPreferences.toString()))
	#end
	$locRenderedPortletContent
	$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, modificado hace 15 años.

RE: Portlets embedded in theme

New Member Mensajes: 6 Fecha de incorporación: 29/04/08 Mensajes recientes
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
thumbnail
Artur Linhart, modificado hace 15 años.

RE: Portlets embedded in theme

Expert Mensajes: 459 Fecha de incorporación: 13/09/07 Mensajes recientes
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


#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.
thumbnail
Ray Augé, modificado hace 15 años.

RE: Portlets embedded in theme

Liferay Legend Mensajes: 1197 Fecha de incorporación: 8/02/05 Mensajes recientes
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...
thumbnail
Artur Linhart, modificado hace 15 años.

RE: Portlets embedded in theme

Expert Mensajes: 459 Fecha de incorporación: 13/09/07 Mensajes recientes
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?
thumbnail
Ray Augé, modificado hace 15 años.

RE: Portlets embedded in theme

Liferay Legend Mensajes: 1197 Fecha de incorporación: 8/02/05 Mensajes recientes
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, modificado hace 15 años.

RE: Portlets embedded in theme

New Member Mensajes: 11 Fecha de incorporación: 3/03/08 Mensajes recientes
Artur, great code!!
thumbnail
Artur Linhart, modificado hace 15 años.

RE: Portlets embedded in theme

Expert Mensajes: 459 Fecha de incorporación: 13/09/07 Mensajes recientes
thank You :-) nice to hear this can help somebody :-)

cheers, Archie
thumbnail
Ray Augé, modificado hace 15 años.

Re: [Liferay Forums][4. Custom Theme Development] RE: Portlets embedded in

Liferay Legend Mensajes: 1197 Fecha de incorporación: 8/02/05 Mensajes recientes
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, modificado hace 14 años.

RE: Portlets embedded in theme

New Member Mensajes: 2 Fecha de incorporación: 6/11/09 Mensajes recientes
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, modificado hace 13 años.

RE: Portlets embedded in theme

New Member Mensajes: 2 Fecha de incorporación: 6/11/09 Mensajes recientes
I was able to get this running by playing with the "instanceable" flag and explicitly setting the instance id in the vm.
thumbnail
anju a anjua, modificado hace 13 años.

RE: Portlets embedded in theme

New Member Mensajes: 6 Fecha de incorporación: 11/01/10 Mensajes recientes
Hi

Thanks for your suggestions.

I have created new theme successfully.. emoticon
thumbnail
Tarun S. Kayasth, modificado hace 14 años.

RE: Portlets embedded in theme

Regular Member Mensajes: 162 Fecha de incorporación: 8/06/07 Mensajes recientes
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
thumbnail
anju a anjua, modificado hace 14 años.

RE: Portlets embedded in theme

New Member Mensajes: 6 Fecha de incorporación: 11/01/10 Mensajes recientes
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, modificado hace 14 años.

RE: Portlets embedded in theme

Regular Member Mensajes: 192 Fecha de incorporación: 18/11/06 Mensajes recientes
portal_normal.vm would be a good place to start.
thumbnail
Artur Linhart, modificado hace 14 años.

RE: Portlets embedded in theme

Expert Mensajes: 459 Fecha de incorporación: 13/09/07 Mensajes recientes
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, modificado hace 13 años.

RE: Portlets embedded in theme

New Member Mensajes: 22 Fecha de incorporación: 14/07/10 Mensajes recientes
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
thumbnail
Artur Linhart, modificado hace 13 años.

RE: Portlets embedded in theme

Expert Mensajes: 459 Fecha de incorporación: 13/09/07 Mensajes recientes
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:

#foreach ($locIterationGroupId in $bckds_theme_community_community_ids_for_article_search)
	#if ($CONST_UNDEFINED.equals($locArticleGroupId))
		#if ($journalArticleLocalService.hasArticle($locIterationGroupId, "$locArticleId"))
			#set ($locArticleGroupId = $locIterationGroupId)
		#end
	#end
#end
#if (!$CONST_UNDEFINED.equals($locArticleGroupId))
	#set ($locGroupAndArticleIdForChecking = "$locArticleGroupId" + "_" + "$locArticleId" + "_")

... etc. see my post with the source code above.
							
Kristian Gil, modificado hace 13 años.

RE: Portlets embedded in theme

New Member Mensajes: 22 Fecha de incorporación: 14/07/10 Mensajes recientes
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:


#set($currentGroup = $layout.getGroup())
#set($locPortletGroupId = $currentGroup.getGroupId())

#set ($locGroupAndArticleIdForChecking = $locPortletGroupId)
$velocityPortletPreferences.setValue("portlet-setup-show-borders", "false")
$velocityPortletPreferences.setValue("group-id", "$locPortletGroupId")
#set ($locPortletId = "1_WAR_stocksportlet")
#set ($locRenderedPortletContent = $theme.runtime($locPortletId, "", $velocityPortletPreferences.toString()))
#set ($locCorrectPortletHasBeenReturned = $locRenderedPortletContent.contains($locGroupAndArticleIdForChecking))
				
#if ($locCorrectPortletHasBeenReturned)
	##correct - let it be
#else
	##incorrect - the article or group Id has been changed - so remove the old porltet preferences record and reinitialize it:
	#set ($locPortletPreferenceService =      $serviceLocator.findService("com.liferay.portal.service.PortletPreferencesLocalService"))
        #set ($locPlidLong = $getterUtil.getLong($plid))
        $locPortletPreferenceService.deletePortletPreferences(0, 3, $locPlidLong, $locPortletId)
	##  ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0 ... PortletKeys.PREFS_OWNER_ID_DEFAULT, 3 ... PortletKeys.PREFS_OWNER_TYPE_LAYOUT
	#set ($locRenderedPortletContent = $theme.runtime($locPortletId, "", $velocityPortletPreferences.toString()))
#end
$locRenderedPortletContent
$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!
thumbnail
Artur Linhart, modificado hace 13 años.

RE: Portlets embedded in theme

Expert Mensajes: 459 Fecha de incorporación: 13/09/07 Mensajes recientes
Hello, Kristian,

sorry 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.

I 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. 

In every case I think, the usage of portlet Id is not correct - You use the code

[code] #set ($locPortletId = "1_WAR_stocksportlet")


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

#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, modificado hace 12 años.

RE: Portlets embedded in theme

New Member Mensajes: 20 Fecha de incorporación: 29/04/11 Mensajes recientes
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
thumbnail
Artur Linhart, modificado hace 12 años.

RE: Portlets embedded in theme

Expert Mensajes: 459 Fecha de incorporación: 13/09/07 Mensajes recientes
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 :-)
thumbnail
Mazhar Alam, modificado hace 12 años.

RE: Portlets embedded in theme

Regular Member Mensajes: 191 Fecha de incorporación: 25/11/11 Mensajes recientes
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
thumbnail
Artur Linhart, modificado hace 12 años.

RE: Portlets embedded in theme

Expert Mensajes: 459 Fecha de incorporación: 13/09/07 Mensajes recientes
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:

$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").
thumbnail
Mazhar Alam, modificado hace 12 años.

RE: Portlets embedded in theme

Regular Member Mensajes: 191 Fecha de incorporación: 25/11/11 Mensajes recientes
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
thumbnail
David H Nebinger, modificado hace 12 años.

RE: Portlets embedded in theme

Liferay Legend Mensajes: 14914 Fecha de incorporación: 2/09/06 Mensajes recientes
A portlet's JSP will probably not work outside of the portlet context. A portlet is more than just it's jsp pages...
thumbnail
Mazhar Alam, modificado hace 12 años.

RE: Portlets embedded in theme

Regular Member Mensajes: 191 Fecha de incorporación: 25/11/11 Mensajes recientes
Thanks..got it...
Pablo Tatann, modificado hace 13 años.

RE: Portlets embedded in theme

Junior Member Mensajes: 62 Fecha de incorporación: 18/11/10 Mensajes recientes
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:

	#set ($locGroupAndArticleIdForChecking = "$locArticleGroupId" + "_" + "$locArticleId" + "_")
	$velocityPortletPreferences.setValue("portlet-setup-show-borders", "false")
	$velocityPortletPreferences.setValue("group-id", "$locArticleGroupId")
	$velocityPortletPreferences.setValue("article-id", "$locArticleId")
	#set ($locPortletId = "56_INSTANCE_" + $globCounterOfThemeDynamicPortletId)
	#set ($globCounterOfThemeDynamicPortletId = $globCounterOfThemeDynamicPortletId + 1)
	#set($locRenderedPortletContent = $theme.runtime($locPortletId, "", $velocityPortletPreferences.toString()))
	#set ($locCorrectArticleHasBeenReturned = $locRenderedPortletContent.contains($locGroupAndArticleIdForChecking))
	#if ($locCorrectArticleHasBeenReturned)
		##correct - let it be
	#else
		##incorrect - the article or group Id has been changed - so remove the old porltet preferences record and reinitialize it:
		#set ($locPortletPreferenceService = $serviceLocator.findService("com.liferay.portal.service.PortletPreferencesLocalService"))
		#set ($locPlidLong = $getterUtil.getLong($plid))
		$locPortletPreferenceService.deletePortletPreferences(0, 3, $locPlidLong, $locPortletId)
		##  ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0 ... PortletKeys.PREFS_OWNER_ID_DEFAULT, 3 ... PortletKeys.PREFS_OWNER_TYPE_LAYOUT
		#set ($locRenderedPortletContent = $theme.runtime($locPortletId, "", $velocityPortletPreferences.toString()))
	#end
	$locRenderedPortletContent
	$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
thumbnail
Artur Linhart, modificado hace 13 años.

RE: Portlets embedded in theme

Expert Mensajes: 459 Fecha de incorporación: 13/09/07 Mensajes recientes
Hello, Pablo,

I have used the standard Web Content Portlet, so no vustom specific porltet. By the code

 $velocityPortletPreferences.setValue("portlet-setup-show-borders", "false")
 $velocityPortletPreferences.setValue("group-id", "$locArticleGroupId")
 $velocityPortletPreferences.setValue("article-id", "$locArticleId")


you set the preferences of the Web Content Portlet and by


#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:

	<portlet>
		<portlet-name>56</portlet-name>
		<display-name>Journal Content</display-name>
		<portlet-class>com.liferay.portlet.StrutsPortlet</portlet-class>
		<init-param>
			<name>view-action</name>
			<value>/journal_content/view</value>
		</init-param>
		<expiration-cache>0</expiration-cache>
		<supports>
			<mime-type>text/html</mime-type>
		</supports>
		<supports>
			<mime-type>application/vnd.wap.xhtml+xml</mime-type>
		</supports>
		<resource-bundle>com.liferay.portlet.StrutsResourceBundle</resource-bundle>
		<security-role-ref>
			<role-name>guest</role-name>
		</security-role-ref>
		<security-role-ref>
			<role-name>power-user</role-name>
		</security-role-ref>
		<security-role-ref>
			<role-name>user</role-name>
		</security-role-ref>
	</portlet> 


At last, by the statement


 #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 Tatann, modificado hace 13 años.

RE: Portlets embedded in theme

Junior Member Mensajes: 62 Fecha de incorporación: 18/11/10 Mensajes recientes
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
thumbnail
Palani Venkat, modificado hace 13 años.

Move Portal changes from dev machine to Production machine

Junior Member Mensajes: 32 Fecha de incorporación: 10/11/10 Mensajes recientes
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
thumbnail
Artur Linhart, modificado hace 13 años.

RE: Move Portal changes from dev machine to Production machine

Expert Mensajes: 459 Fecha de incorporación: 13/09/07 Mensajes recientes
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 Tatann, modificado hace 13 años.

RE: Move Portal changes from dev machine to Production machine

Junior Member Mensajes: 62 Fecha de incorporación: 18/11/10 Mensajes recientes
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
thumbnail
Artur Linhart, modificado hace 13 años.

RE: Portlets embedded in theme

Expert Mensajes: 459 Fecha de incorporación: 13/09/07 Mensajes recientes
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 Tatann, modificado hace 13 años.

RE: Portlets embedded in theme

Junior Member Mensajes: 62 Fecha de incorporación: 18/11/10 Mensajes recientes
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
thumbnail
Artur Linhart, modificado hace 13 años.

RE: Portlets embedded in theme

Expert Mensajes: 459 Fecha de incorporación: 13/09/07 Mensajes recientes
how do You edit Your article shown in the theme, if the content of the article displayed in the theme stays unchanged?
satish M, modificado hace 13 años.

RE: Portlets embedded in theme

New Member Mensajes: 23 Fecha de incorporación: 1/12/10 Mensajes recientes
sorry i am not understand.
can you explain what is the IDE forLiferay 5.1.2 IDE and how to cinfigure..
Pablo Tatann, modificado hace 13 años.

RE: Portlets embedded in theme

Junior Member Mensajes: 62 Fecha de incorporación: 18/11/10 Mensajes recientes
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
thumbnail
Artur Linhart, modificado hace 13 años.

RE: Portlets embedded in theme

Expert Mensajes: 459 Fecha de incorporación: 13/09/07 Mensajes recientes
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 Tatann, modificado hace 13 años.

RE: Portlets embedded in theme

Junior Member Mensajes: 62 Fecha de incorporación: 18/11/10 Mensajes recientes
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
thumbnail
Artur Linhart, modificado hace 13 años.

RE: Portlets embedded in theme

Expert Mensajes: 459 Fecha de incorporación: 13/09/07 Mensajes recientes
OK, glad to help You :-)
Pablo Tatann, modificado hace 13 años.

RE: Portlets embedded in theme

Junior Member Mensajes: 62 Fecha de incorporación: 18/11/10 Mensajes recientes
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
thumbnail
Palani Venkat, modificado hace 13 años.

RE: Portlets embedded in theme

Junior Member Mensajes: 32 Fecha de incorporación: 10/11/10 Mensajes recientes
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, modificado hace 13 años.

RE: Portlets embedded in theme

New Member Mensajes: 23 Fecha de incorporación: 1/12/10 Mensajes recientes
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 _, modificado hace 13 años.

RE: Portlets embedded in theme

Junior Member Mensajes: 92 Fecha de incorporación: 2/03/07 Mensajes recientes
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.
thumbnail
Artur Linhart, modificado hace 13 años.

RE: Portlets embedded in theme

Expert Mensajes: 459 Fecha de incorporación: 13/09/07 Mensajes recientes
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 _, modificado hace 13 años.

RE: Portlets embedded in theme

Junior Member Mensajes: 92 Fecha de incorporación: 2/03/07 Mensajes recientes
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, modificado hace 13 años.

RE: Portlets embedded in theme

New Member Mensaje: 1 Fecha de incorporación: 9/01/11 Mensajes recientes
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:
#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:


#set ($globCounterOfThemeDynamicPortletId = 1000)
#set ($locArticleId = <insert article number>)
#set ($locArticleGroupId = <insert group id>)
#set ($locGroupAndArticleIdForChecking = "$locArticleGroupId" + "_" + "$locArticleId" + "_")
$velocityPortletPreferences.setValue("portlet-setup-show-borders", "false")
$velocityPortletPreferences.setValue("group-id", "$locArticleGroupId")
$velocityPortletPreferences.setValue("article-id", "$locArticleId")
#set ($locPortletId = "56_INSTANCE_" + $globCounterOfThemeDynamicPortletId)
#set ($globCounterOfThemeDynamicPortletId = $globCounterOfThemeDynamicPortletId + 1)
#define($locRenderedPortletContent)$theme.runtime($locPortletId, "", $velocityPortletPreferences.toString())#end
#define($locCorrectArticleHasBeenReturned)$locRenderedPortletContent.contains($locGroupAndArticleIdForChecking)#end
#if ($locCorrectArticleHasBeenReturned)
	##correct - let it be
#else
	##incorrect - the article or group Id has been changed - so remove the old porltet preferences record and reinitialize it:
	#set ($locPortletPreferenceService = $serviceLocator.findService("com.liferay.portal.service.PortletPreferencesLocalService"))
	#set ($locPlidLong = $getterUtil.getLong($plid))
	$locPortletPreferenceService.deletePortletPreferences(0, 3, $locPlidLong, $locPortletId)
	##  ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0 ... PortletKeys.PREFS_OWNER_ID_DEFAULT, 3 ... PortletKeys.PREFS_OWNER_TYPE_LAYOUT
	#define($locRenderedPortletContent)$theme.runtime($locPortletId, "", $velocityPortletPreferences.toString())#end
#end
$locRenderedPortletContent
$velocityPortletPreferences.reset()
</insert></insert>
gofri _, modificado hace 13 años.

RE: Portlets embedded in theme

Junior Member Mensajes: 92 Fecha de incorporación: 2/03/07 Mensajes recientes
I choose another solution at the end:

   #set ($locArticleId = 10111)
   #set ($locArticleGroupId = 10222)
			
   #set ($script_and_style_includes =    $journalContentUtil.getContent($getterUtil.getLong("$locArticleGroupId"), "$locArticleId", "", "view", "en", $themeDisplay))
   
   $script_and_style_includes


This doesn't create a row in a portletPreferences table and looks more flexible.
thumbnail
Artur Linhart, modificado hace 13 años.

RE: Portlets embedded in theme

Expert Mensajes: 459 Fecha de incorporación: 13/09/07 Mensajes recientes
Well, it looks interesting, thank You :-)
Pablo Tatann, modificado hace 13 años.

RE: Portlets embedded in theme

Junior Member Mensajes: 62 Fecha de incorporación: 18/11/10 Mensajes recientes
gofri _:
I choose another solution at the end:

   #set ($locArticleId = 10111)
   #set ($locArticleGroupId = 10222)
			
   #set ($script_and_style_includes =    $journalContentUtil.getContent($getterUtil.getLong("$locArticleGroupId"), "$locArticleId", "", "view", "en", $themeDisplay))
   
   $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