Combination View Flat View Tree View
Threads [ Previous | Next ]
Showing 1 - 20 of 62 results.
of 4
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: 459

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

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

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

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

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

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

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.
Tarun S. Kayasth
RE: Portlets embedded in theme
April 13, 2009 6:44 AM
Answer

Tarun S. Kayasth

Rank: Regular Member

Posts: 160

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
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?
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: 192

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:
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.
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: 192

Join Date: November 17, 2006

Recent Posts

portal_normal.vm would be a good place to start.
Showing 1 - 20 of 62 results.
of 4