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



 

  
     



Monday 28 October 2013

Accessing custom service in theme

Follow the bellow steps to access Custom Service in liferay Theme.

1. Build your service and deploy the portlet into liferay portal.

2. set the bellow portal property value empty, by default it holds serviceLocator

journal.template.velocity.restricted.variables=

3. in vm file where you want to access the service, write the bellow line of code
 
#set($customLocalService=$serviceLocator.findService('your portlet name'),'package.entityLocalservice')

in the above code
  i.customLocalService  is the Custom Variable (User Defined)
  ii. your portlet name is the portlet name,  if you mentioned the portlet name means it will help the service locator to to find the service with in the portlet, ( i.e the portlet name you mentioned), if you pass empty values than service locator will search the service with portal.
 iii. Package is the package path of the service
 iv. entityLocalservice is the local service name

4.after the step 3, variable customLocalService,  will hold the reference of localservice impl class by using this you can access all the method in local service impl class.

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

Monday 18 February 2013

Changing portlet title dynamically at run time.

This Blog is to explain how to change the portlet title dynamically at run time. This can be done in two ways one in client side and other one in server side.

1. In server side you can do it by using render response object in your do-view method 
  exmple:=> renderResponseObject.setTitle("Give your choice title here");

2. in client side you can change it by using bellow java script function.
 example: 
document.getElemetById("portlet-id").getElementsByTagName("span")[1]. innerHTML="Give your choice title here";

add the above code into your xhtml or jsp page that is your view page, when page is loaded.means write inside onpage load function

Here in above client side code, to get portlet id in your liferay portal go to---> settings-->advance Styling, there you can find portlet id, copy and paste it in place of portlet id. copy portlet id after #symbol