Wednesday, December 26, 2012

Template : some important variable in template(.vm)

Hi All,

   Many time we use webcontent OOTB functionality for our solution. for that we also use Structure/Template. here Template is render part of WebContent. so many time developer stuck with how to get value of some important properties like theme-dispaly,scopegroupid,image path, etc. so, here give some instruction for that.

1) to get instance of class (some times we can't get accesss class by serviceLocator.findService())
$portal.getClass().forName("com.liferay.portlet.dynamicdatamapping.storage.StorageEngineUtil").newInstance()   

2)currentScopegroupid 
    - $getterUtil.getLong($request.get("theme-display").get("scope-group-id"))
    - $request.theme-display.scope-group-id
3) images path in theme
    $request.get("theme-display").path-theme-images
4) themeDispaly
    $request.theme-display
5) globalScopeGroupId
    $groupId

5) find service
 $serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService")


Enjoy!!!

Wednesday, December 19, 2012

Servidce/Util classes access in template (.vm) file in Liferay

Hi Developers,

Many times you need to access services/util class in template. 

Below is some importance hits for the same.

=> Access services using findService method in Velocity(vm)

#set ($userLocalService= $serviceLocator.findService("com.liferay.portal.service.UserLocalService"))
=>Access util class using  findUtil Method for inbuilt Util of Liferay
#set ($journalContentUtil = $utiLocator.findUtil("com.liferay.portlet.journalcontent.util.JournalContentUtil"))
=> some times you also need to access util class which is not have access in template file like StorageEngineUtil. for that you can use below approch..

#set ($util = $portal.getClass().forName("com.liferay.portlet.dynamicdatamapping.storage.StorageEngineUtil").newInstance()) 


HTH.. :))

Wednesday, December 12, 2012

Audio play in portlet using flowplayer.....



For mp3 audio file play you need below plugin swf & js file.

flowplayer.controls-3.2.14.swf
flowplayer.audio-3.2.10.swf
flowplayer-3.2.15.swf
flowplayer-3.2.6.min.js

and here is the sample code snippet to play mp3 audio file which in document library....

<< script type="text/javascript" src="/video-portlet/js/flowplayer-3.2.6.min.js"></script>

<< a href="http://localhost:8080/documents/10180/f7804b0c-9001-4f59-a7b2-45dcbceae8ca" style="display:block;width:520px;height:330px" id="unsecure">
            </a>
<< script type="text/javascript">
        $f("unsecure", "/video-portlet/flowplayer-3.2.15.swf",
                {
                    plugins: {
                        controls: {
                            fullscreen: true,
                            height: 30,
                            autoHide: false
                        },
                        audio: {
                            url: '/video-portlet/flowplayer.audio-3.2.10.swf'
                        }
                    },
                    clip:  {
                         provider: "audio"
                    }
                }
       
       
            );

        </script>


NOTE: "http://localhost:8080/documents/10180/f7804b0c-9001-4f59-a7b2-45dcbceae8ca" is a document library file url.