Tuesday 5 November 2013

Accessing the site private and public page in Theme.

Fallow the bellow steps to access site private and public pages in theme.

1. #foreach($site in $user.mySites) ------- # end,
loop user site to get the site information to which the user belongs to,

2. as i explained in my previous to the bellow line of code will give you the LAYOUTLOCALSERVICEIMPL calss to access all the method in this class.   

#set ($layoutLocalService = $serviceLocator.findService("com.liferay.portal.service.LayoutLocalService"))

3. bellow line of code will give you the public and private layouts of the particular site

#set ($globalLayouts_private = $layoutLocalService.getLayouts($group.groupId, true, 0))

#set ($globalLayouts_public = $layoutLocalService.getLayouts($group.groupId, false, 0))
 
in the above line of code.
   a. layoutLocalService is the localLayoutServiceImpl class object.
   b. getLayouts is the method in the localLayoutServiceImpl class to get the public and private layout information
    c. argument  $group.groupId is the site id, you can get the group information through user object.
        ex:  $group in $user.getGroups(), 
       Note: don't get confuse group is nothing but site. 
   d. argument Boolean value is for accessing private or public page information
       ex: true is for public and false is for private
 
4 . than iterate the $globalLayouts_private & $globalLayouts_public this will contain the private and public site page information.

ex: 1.  #foreach ($private_layout in $globalLayouts_private)
      <a href="$portalUtil.getLayoutFriendlyURL($private_layout, $heme_display)"   $private_layout.getTarget()>$private_layout.getName($locale)</a>
         #end

     2. #foreach ($public_layout in $globalLayouts_public)
                                                        <a href="$portalUtil.getLayoutFriendlyURL($public_layout, $theme_display)" $public_layout.getTarget()>$public_layout.getName($locale)</a>
                                                                    #end     



I hope this blog may help you.......................



 

  
     



No comments:

Post a Comment