Monday, February 21, 2011

Enable OpenOffice in liferay

To enable document conversion in the Document Library portlet, follow the instructions bellow:

For Windows user


1)      Install OpenOffice.org v2.0.3 or higher (has been tested on many versions, include 3.2).
2)      Go to the folder where it was installed (for example, C:\Program Files\OpenOffice.org\program) and start OpenOffice service with the following command:
soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard


For Linux user
1)      Goto Openoffice installing path.From command prompt type this line
 "cd /usr/lib/openoffice/program"

  2)   Same command prompt copy & paste this code
"sudo soffice "-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" -nologo -headless –nofirststartwizard"

In latest linux we need run this commend with user name ubuntu 10.4 + use this code it will ask password give your root user password..
"sudo -H -u root /usr/lib/openoffice/program/soffice "-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" -nologo -headless -nofirststartwizard"


For Mac user


1)      If you are running on Mac OS X, then you should run the following from the Terminal program (note that this is assuming you are running Open Office and it is installed in your /Applications directory.
/Applications/OpenOffice.org.app/Contents/MacOS/soffice "-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager" -nologo -headless
In liferay GUI


2)      Go to control panel then click on the Server Administration tab, then OpenOffice tab. Click on enable, in case OpenOffice is listening to a different port change the it accordingly.

Places where this integration is used.

1)      Document Library portlet
You should see this when you View a document in Document Library, click on the desired conversion.

2)      Web content Display
You should see this when you click configuration select which are the format guest could download. Then click save button show the option to guest.

Sunday, February 20, 2011

Display hidden childs page in Liferay Footer

Step1. Add these lines into portal_normal.vm under this path your_theme/docroot/_diff/templates. (for importing bottom navigation files)
Add this inside the footer div  
#if ($has_navigation)
           #parse ("$full_templates_path/bottom_navigation.vm")
     #end
Step2. Create bottom_navigation.vm under this path  your_theme/docroot/_diff/templates
<table width="100%">
     <tr>
           <td>
                #set($layoutLocalServiceUtil = $serviceLocator.findService("com.liferay.portal.service.LayoutLocalService"))
                #set($topPublicLayouts = $layoutLocalServiceUtil.getLayouts($layout.getGroupId(),false))
                #foreach ($lay_item in $topPublicLayouts)
                     #if ($lay_item.isHidden())
                           #if ($lay_item.getFriendlyURL() == "/footer-links")
                                <div id="footer-links">
                                     #foreach ($child in $lay_item.getChildren())
                                           <a href="$company_url$child.getFriendlyURL()">$child.getName()</a>
#end   
                           </div>
                           #end
                     #end    
                #end 
          </td>
    <tr>
</table>
Note: Here we are using pages is footer links as hidden parent page, based on your requirement you need charges this line. You need put your page URL.
 #if ($lay_item.getFriendlyURL() == "/footer-links")
Step3. Add these lines into custom.css under this path your_theme/docroot/_diff/custom.css
/**************** Footer Links *******/
/**************** Based on your requirements changes colors *******/
#footer{
      border-top:1px solid #DDD;
      text-align:left;
      margin:0auto;
      max-width:960px;
      margin-top:10px;
}
#footer-linksa,#footer-linksspan {
      color:#2A72C9;
      text-decoration:none;
      font:normal12px 'Lucida Sans Unicode','Lucida Grande',Tahoma,sans-serif;
      padding:2px0px;
}

#separator{
      height:13px;
      margin:0px8px;
      padding:2px0px;
      border-right:1pxdotted #ccc;
}
#footer-linksa:hover{
      text-decoration:underline;
}
Step4. Then ant deploy fromyour theme level

Adding Google Translator in a Liferay portal

People always prefer their native language for their convence. To browse a website with a feature of tranlsation is what most of them would like. Liferay provides a feature where in we can have our portal in different languages. This is achieved using  Language-ext.properties file.

But there are few drawbacks in using the above.
The  drawbacks are :
1.This requires a customisation in all the Language_xx.properties file. (For eg. If we want 30 languages option then 30 Language_xx.properties files need to be customised).

2.Even after doing so the entire portal is not changed to the language selected,only the variables mentioned in the  Language_xx.properties file are changed and anything from database is not changed.

So here is the convenient solution of having your portal in different languages by integrating the Google's API in two simple steps

Step1:

Copy and paste the below snippet code in the "portal_normal.vm"
file
<div id="google_translate_element"></div>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.
translate.TranslateElement({
pageLanguage: 'en',
layout: google.
translate.TranslateElement.InlineLayout.SIMPLE
}, 'google_translate_element');
}
</script>
<script src="//
translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

Step 2:
We can further change the position of the translate tab. To change the display mode in Horizontal, change the layout to
  layout: google.translate.TranslateElement.InlineLayout.HORIZONTAL
For Bottom-right Position:    floatPosition: google.translate.TranslateElement.FloatPosition.BOTTOM_RIGHT
For Bottom-left Position:    floatPosition: google.translate.TranslateElement.FloatPosition.BOTTOM_LEFT

and so on..

To use the the Google's translator only in the selected sections of a website, we can use the below code

<script>
          function googleSectionalElementInit() {
new google.translate.SectionalElement({
sectionalNodeClassName: 'goog-trans-section',
controlNodeClassName: 'goog-trans-control',
background: '#99ff99'
}, 'google_sectional_element');
}
</script>
<script src="//translate.google.com/translate_a/element.js?cb=googleSectionalElementInit&ug=section&hl=auto"></script>

Add an element with a class name “goog-trans-section”  and a child element with class name “goog-trans-control”. On clicking the parent element, the contents within the child element will be translated.

Note: We can further customise the look and feel of the Google translator toolbar by strictly maintaining the Google trademark and logos.

The following are the merits and demerits of Liferay's translation and other translation APIs (eg. Google Translator)

Liferay's Translation

 Merits  1.Its looks professional
 2.Performance will not be affected.
 3.Translation of the content will be controlled by ourselves.

Demerits

 1.It will not translate Dynamic contents
 2.Static contents need to be mentioned in properties files manually
 3.The number of properties file increases as a number of language increases
 4.For CMS (i.e Web content and page navigations) we need to create articles in the                
respective languages seperately


Google and others Translation tools :

 Merits  1.No need of any properties file changes
 2.Dynamic content as well as static content will be translated in the respective languages
 3.For Web content and page navigations need not create articles in different languages
 4.Imlementation is easy.

De Merits
 1.Performance issue.
 2.The translation control is handled by third party
 3.We need to adhere to the terms & condition of the third party
 4.We don't have control over any issues that are caused by the third party applications .