Foren

Navigation having public and private pages links

Gaurish Sharma, geändert vor 15 Jahren.

Navigation having public and private pages links

New Member Beiträge: 22 Beitrittsdatum: 23.01.09 Neueste Beiträge
Hi

While creating community web site I have set up 10 private pages that needs authentication. And I have set up 5 public pages that do not require authentication.

The problem is that using the code that is there in navigation.vm I can either display navigation items that correspond to public pages or private pages but not both.

Is there a possibility of having a merged navigation; i.e. a navigation where I can have access to both private and public pages? Also, I want this navigation tree (having both public and private page links) to be visible to guest users and only when they click on a private page link they are challenged for authentication.

Thanks
Gaurish
thumbnail
Joe Shum, geändert vor 15 Jahren.

RE: Navigation having public and private pages links

Expert Beiträge: 336 Beitrittsdatum: 17.05.06 Neueste Beiträge
this feature of merged private and public layouts is not available.
how about putting roles around some of these layouts and removing guest from others on the public LayoutSet?
thumbnail
Victor Zorin, geändert vor 15 Jahren.

RE: Navigation having public and private pages links

Liferay Legend Beiträge: 1228 Beitrittsdatum: 14.04.08 Neueste Beiträge
You can do it, by changing your template vm files. It will work as you need, ie. showing public links and private ones, and requesting authentication when going to private.
The only handicap remains that you will probably have to hardcode those private links, as when user is not signed-in portal is not aware which communities this user belongs to. In your specific case, you know which ones will have to go into public navigation menu, so you can safely stick them in.
Andrew Tillinghast, geändert vor 14 Jahren.

RE: Navigation having public and private pages links

Junior Member Beiträge: 60 Beitrittsdatum: 05.09.08 Neueste Beiträge
We just got this to work for our portal, we have one community that all members are part of and we wanted to always show that Nav and and the Nav for the user's private pages together.

in init_custom.vm

#set ($groupService=$serviceLocator.findService("com.liferay.portal.service.GroupService"))
#set ($communityGroup=$groupService.getGroup($company_id,"CamelWeb"))

#set ($layoutlocalService=$serviceLocator.findService("com.liferay.portal.service.LayoutLocalService"))
#if ($layout.getGroup() == $user.getGroup())
	#set ($ComPages = $layoutlocalService.getLayouts($communityGroup.getGroupId(),true,0))
#else
	#set ($UserPages = $layoutlocalService.getLayouts($user_group.getGroupId(),true,0))
#end


and navigation.vm

<div id="navigation" class="sort-pages modify-pages">
	<ul>
		#if($ComPages)
			#foreach ($ComPage in $ComPages)
				#if($layoutPermission.contains($permissionChecker, $ComPage , "VIEW"))
					<li>
					<a href="$ComPage.getRegularURL($request)" $compage.gettarget()><span>$ComPage.getName($locale)</span></a>
					</li>
				#end
			#end
		#end
		#foreach ($nav_item in $nav_items)
			#if ($nav_item.isSelected())
				#set ($nav_item_class = "selected")
			#else
				#set ($nav_item_class = "")
			#end

			<li class="$nav_item_class">
				<a href="$nav_item.getURL()" $nav_item.gettarget()><span>$nav_item.getName()</span></a>

				#if ($nav_item.hasChildren())
					<ul class="child-menu">
						#foreach ($nav_child in $nav_item.getChildren())
							#if ($nav_child.isSelected())
								#set ($nav_child_class = "selected")
							#else
								#set ($nav_child_class = "")
							#end

							<li class="$nav_child_class">
								<a href="$nav_child.getURL()" $nav_child.gettarget()>$nav_child.getName()</a>
							</li>
						#end
					</ul>
				#end
			</li>
		#end
		#if($UserPages)
			#foreach ($UserPage in $UserPages)
				#if($layoutPermission.contains($permissionChecker, $UserPage , "VIEW"))
					<li>
					<a href="$UserPage.getRegularURL($request)" $userpage.gettarget()><span>$UserPage.getName($locale)</span></a>
					</li>
				#end
			#end
		#end
	</ul>
</div>


Right now not showing child pages ( we aren't using them) and only showing our one community. However the code in init_custom.vm could be modified to iterate over the list of user's group and merge tabs for all groups if desired.
thumbnail
Abdelrahman Mohamed El Ghanam, geändert vor 13 Jahren.

RE: Navigation having public and private pages links

Junior Member Beiträge: 41 Beitrittsdatum: 30.09.10 Neueste Beiträge
Worked like a charm thanks a lot Andrew.
shahab alam, geändert vor 6 Jahren.

RE: Navigation having public and private pages links

New Member Beiträge: 5 Beitrittsdatum: 09.06.17 Neueste Beiträge
Even, i want to use bit similar feature, that my navigation menu should always show public links in header section irrespective of the private/public page view. How to show public navigation menu in header through theme - liferay 7 using freemarker template. Any suggestion?
thumbnail
Olaf Kock, geändert vor 6 Jahren.

RE: Navigation having public and private pages links

Liferay Legend Beiträge: 6403 Beitrittsdatum: 23.09.08 Neueste Beiträge
Keep an eye on my ancient Custom Navigation plugin on Marketplace. I'm intending to submit an update next week - once that's approved, it'll be available for Liferay 7 and DXP as well. The 6.1 code is also linked from there, it's not a lot and migration is quite simple.
shahab alam, geändert vor 6 Jahren.

RE: Navigation having public and private pages links

New Member Beiträge: 5 Beitrittsdatum: 09.06.17 Neueste Beiträge
Thanks for your reply Olaf. eagerly waiting for your update emoticon
thumbnail
Olaf Kock, geändert vor 6 Jahren.

RE: Navigation having public and private pages links

Liferay Legend Beiträge: 6403 Beitrittsdatum: 23.09.08 Neueste Beiträge
If you want to compile for yourself instead of waiting- this weekend I've uploaded the code to github
suji h, geändert vor 6 Jahren.

RE: Navigation having public and private pages links

New Member Beiträge: 2 Beitrittsdatum: 22.03.18 Neueste Beiträge
Thank you for always.
I have a question about the Custom Navigation plugin.
I have installed the plug-in on Liferay 7.0 ga5.
And I inserted the ID of the newly added site in the custom fields of the main site.
(I will attach the screen to the file.)
 But the newly added site does not look like the fourth picture in the plugin description.
Only the page (welcome) of Liferay (main site) is visible.
I want to know what was wrong.
Also, I wonder if you can put both the private page and the public page in the navigation menu like site.
thumbnail
Olaf Kock, geändert vor 6 Jahren.

RE: Navigation having public and private pages links

Liferay Legend Beiträge: 6403 Beitrittsdatum: 23.09.08 Neueste Beiträge
The entries for both, public and private navigation, should be
31412,public
31412,private

This will make sure that your public pages are listed first, then your private pages - independent of the page set (public or private) that you're currently showing.
suji h, geändert vor 6 Jahren.

RE: Navigation having public and private pages links

New Member Beiträge: 2 Beitrittsdatum: 22.03.18 Neueste Beiträge
Thank you for your help.
Thanks to the app, I was able to solve the problem quickly and easily.