« Back to Dockbar

Link to Dockbar

Table of Contents [-]

Introduction #

For a lot of Liferay implementations, the dockbar needs to be hidden and the "Add Application" button and the "Layout Templates" button need to be placed on the site body. Unfortunately, doing that has not been the easiest thing to figure out. Fortunately, there does exist an easy way to do it.

Code #

If you place this code anywhere in portal_normal.vm, it links to the "Add Application" container as well as the "Layout Templates" container.

<!-- This can be placed anywhere in the portal_normal.vm -->
<a href="javascript:;" id="addApplications">Add Application</a>
<a href="javascript:;" id="layoutTemplates">Layout Templates</a>
<script type="text/javascript">
	AUI().use(
		'aui-dialog',
		'liferay-layout-configuration',
		function(A) {
			// Create the Add Applications dialog
			var addApplicationsDialog = new A.Dialog({
				title: 'Add Application',
				width: 280,
				visible: false
			}).plug(A.Plugin.IO, {
				after: {
					success: function(event, id, obj) {
						Liferay.LayoutConfiguration._dialogBody = addApplicationsDialog.get('contentBox');
						Liferay.LayoutConfiguration._loadContent();
					}
				},
				autoLoad: false,
				data: {
					doAsUserId: themeDisplay.getDoAsUserIdEncoded(),
					p_l_id: themeDisplay.getPlid(),
					p_p_id: 87,
					p_p_state: 'exclusive'
				},
				showLoading: false,
				uri: themeDisplay.getPathMain() + '/portal/render_portlet'
			});

			// Attach the click listeners to the links
			A.one('#addApplications').on('click', function(event) {
				addApplicationsDialog.render().show().io.start();
			});

			A.one('#layoutTemplates').on('click', function(event) {
				Liferay.LayoutConfiguration.showTemplates();
			});
		}
	);
</script>
0 Attachments
65853 Views
Average (9 Votes)
The average rating is 4.66666666666667 stars out of 5.
Comments
Threaded Replies Author Date
It was very helpful. I spend days to findout... Olcay Yüce August 4, 2010 1:14 AM
Is there something similar for toggle edit... Jules OU August 19, 2010 12:06 AM
AUI().use( 'aui-dialog', ... Jules OU August 25, 2010 2:31 AM
If i want to display the contents without popup... Nagendra Kumar Busam November 11, 2010 3:07 AM
HI Jules, I tried to add toggle edito control... Dhrutika Vyas August 29, 2013 7:09 AM
See my earlier comment. ... S L B August 29, 2013 7:17 AM
Thanks S L B for quick reply. Yes I read that... Dhrutika Vyas August 29, 2013 10:31 PM
Hi, Do you have the same thing for... Dan Smith September 9, 2010 10:18 AM
I too would like a way to disable the myPlaces... James Denmark September 11, 2010 4:57 PM
Works great! For our setup, I only had to make... Patrick Stackpoole November 15, 2010 2:49 PM
Thanks a lot for this code but it doesn't seem... Serge Bajda May 19, 2011 9:02 AM
Dear All, My requirement is I need different... Dinesh Balaji July 4, 2011 3:34 AM
Is the a similar solution for the 'add page'... Gem E November 17, 2011 8:06 PM
I'd like to know if there is a similar solution... A Herrera January 20, 2012 12:14 PM
Here's what I was able to figure out: In the... A Herrera January 25, 2012 2:01 PM
Dragging is not working on the component. I... Jawwad Farooq June 28, 2012 4:50 AM
Hi All, I tried with the above snippets... Jatin Panchal July 19, 2012 6:39 AM
Liferay.Util.toggleControls() actually adds the... S L B August 2, 2012 12:29 PM
Liferay.LayoutConfiguration.showTemplates is... Tran Hong Quan September 5, 2012 9:27 AM
Has anyone figured out how to make the link to... Dahai Zheng June 28, 2013 2:28 PM
How to place "Add Page" link to allow user to... Ravi Soni September 14, 2012 5:25 AM
Adding a shameless plug here because others may... Nick Piesco January 10, 2014 7:49 AM
How to write the same for 6.2 , it works great... Srinivas KK June 21, 2014 10:54 AM
Did you find any updated post for 6.2 GA3 ? All... Achmed Tyrannus Albab February 17, 2015 9:21 PM