掲示板

Providing links to Add Portlet and Change Layout in Liferay 6.1?

12年前 に Joe Moran によって更新されました。

Providing links to Add Portlet and Change Layout in Liferay 6.1?

New Member 投稿: 19 参加年月日: 12/01/05 最新の投稿
A while back, I found this link on the Liferay wiki, which details how to provide a general user with a link to the dockbar's Add Portlet and Change Layout functionality. My group is investigating Liferay 6.1, and we've found that the code on that wiki page is not compatible with whatever code changes have been make to Liferay with the latest release.

Specifically, I've observed the following:
  • The "Add Portlet" dialog that gets displayed has different CSS rendering than what shows up when I select the menu normally from the Dock Bar -- when a category is expanded, the portlets have larger vertical spacing in the version opened by the stand-alone link.
  • I'm unable to use drag-n-drop on any portlet -- I have to click the "Add" button, which puts the portlet in the default first drop zone, and then drag it to where I really want it.
  • Clicking the Change Layout link triggers a JavaScript exception due to a null pointer reference.


Has anyone here updated the code from that wiki page to a form that will work in Liferay 6.1? I'm starting to try and trace through the code myself to figure out the fix, but I figured I'd ask here as well in case it saves me some time. :-)

If I haven't heard back by the time I've worked it out, I'll post an update with the solution here.
12年前 に Joe Moran によって更新されました。

RE: Providing links to Add Portlet and Change Layout in Liferay 6.1?

New Member 投稿: 19 参加年月日: 12/01/05 最新の投稿
Want to give an update on my progress so far.

I'm having little luck in tracking down a way to make this work. I've found that the null reference in the function call for "Change Layout" is the function Liferay.LayoutConfiguration.showTemplates() itself -- in 6.1, there is no such function on the LayoutConfiguration object. I found a function named "toggle()", but this doesn't seem to work either (gives different errors). I haven't had any success finding any other function defined in LayoutConfiguration that works.

As far as the behavior of the "Add Application" link behavior, I can't find anything that directly clues me in to why it behaves so differently when opened as a YUI Dialog vs when it's opened in the Dockbar as an Underlay instance. Even worse, if I log in a regular user instead of an Admin (the whole point of this link code), a bad script error comes up when I click the link:

h.DEFAULT_LAYOUT_OPTIONS is undefined


The error is thrown from the aggregated JS code in "everything.jsp", so no real easy way to figure out where this is coming from. So far, I've found that there is a DEFAULT_LAYOUT_OPTIONS object defined as part of the init() method defined for the Liferay.Layout object, but it looks like maybe the init() method is not being invoked or a regular user (although I see the Liferay.Layout object in Firebug). This error causes the Add Application dialog to break even worse than it did when I viewed it as an Admin. At least as an Admin, I could open categories in the tree and then click an individual app's "Add" link. When this error gets thrown for a regular user, I can't even expand a category heading in the dialog.

If anyone has looked and this and is able to help, please post on this thread. This is functionality I absolutely need for my portal site, and any help I can get in making this work will be much appreciated.
thumbnail
12年前 に Andreas Friedel によって更新されました。

RE: Providing links to Add Portlet and Change Layout in Liferay 6.1?

New Member 投稿: 3 参加年月日: 09/04/06 最新の投稿
If you can give your user the permission Manage Pages you can get around this error.
11年前 に Shiho Pingali によって更新されました。

RE: Providing links to Add Portlet and Change Layout in Liferay 6.1?

New Member 投稿: 12 参加年月日: 11/12/20 最新の投稿
Did everyone solve this problem? If so, please tell me how. I did give permission to the user to customize the page but still not able add application to the page. The application menu dialog pops up but when I try to open the category (plus icon), it doesn't expand because of the javascript error. I am using custom theme with "Add Application" link.
11年前 に Shiho Pingali によって更新されました。

RE: Providing links to Add Portlet and Change Layout in Liferay 6.1?

New Member 投稿: 12 参加年月日: 11/12/20 最新の投稿
I ended up writing a hook to fix this js error and it's working for me now. I made the following change in the layout_configuration.js.
Before change:

var portletItemOptions = {
		delegateConfig: {
			container: '#portal_add_content',
			dragConfig: {
					clickPixelThresh: 0,
					clickTimeThresh: 0
			},
			invalid: '.lfr-portlet-used',
			target: false
			},
			dragNodes: '.lfr-portlet-item',
			dropContainer: function(dropNode) {
			return dropNode.one(layoutOptions.dropContainer);
			},
		on: Layout.DEFAULT_LAYOUT_OPTIONS.on
 };

After change:

 var portletItemOptions = null;
 if(typeof Layout.DEFAULT_LAYOUT_OPTIONS!="undefined"){
        portletItemOptions = {
	          delegateConfig: {
				container: '#portal_add_content',
				dragConfig: {
						clickPixelThresh: 0,
						clickTimeThresh: 0
				},
				invalid: '.lfr-portlet-used',
				target: false
				},
				dragNodes: '.lfr-portlet-item',
				dropContainer: function(dropNode) {
				return dropNode.one(layoutOptions.dropContainer);
				},
			on: Layout.DEFAULT_LAYOUT_OPTIONS.on
        };
 }else{
        portletItemOptions = {
		delegateConfig: {
			container: '#portal_add_content',
				dragConfig: {
					clickPixelThresh: 0,
					clickTimeThresh: 0
				},
				invalid: '.lfr-portlet-used',
				target: false
				},
				dragNodes: '.lfr-portlet-item',
				dropContainer: function(dropNode) {
				return dropNode.one(layoutOptions.dropContainer);
				}
	};
   }


If you get "i is undefined" error, add the following line in portal-ext.properties
javascript.fast.load=false
11年前 に Robert Kornmesser によって更新されました。

RE: Providing links to Add Portlet and Change Layout in Liferay 6.1?

Junior Member 投稿: 39 参加年月日: 11/11/03 最新の投稿
However this does not solve the not-dragable problem and the i is undefined problem.
11年前 に Robert Kornmesser によって更新されました。

RE: Providing links to Add Portlet and Change Layout in Liferay 6.1?

Junior Member 投稿: 39 参加年月日: 11/11/03 最新の投稿
Robert Kornmesser:
However this does not solve the not-dragable problem and the i is undefined problem.


Sorry, just the Drag-and-Drop Problem has to be solved. Its not possible to drag the portlets from the Dialog to their destination. How can this be solved?
7年前 に osama yaccoub によって更新されました。

RE: Providing links to Add Portlet and Change Layout in Liferay 6.1?

New Member 投稿: 8 参加年月日: 16/08/28 最新の投稿
Actually I had the same problem and the cause was that some one was modifying the theme we were using and deleted this line
$theme.include($bottom_include)

by mistake while modifying the main vm file in the theme project .... causing many of the theme functionality to stop