Wednesday 24 April 2013

display journal article using structure and template

#set ($journalArticleLocalService = $serviceLocator.findService('com.liferay.portlet.journal.service.JournalArticleLocalService'))
#set ($curArticle = $journalArticleLocalService.getArticle($groupId,'10717'))
## get current value 10717 is article id
#set ($document = $saxReaderUtil.read($curArticle.getContent()))
#set ($root = $document.getRootElement())
#set ($contentC = $root.selectSingleNode("static-content")) 
${contentC.text}

This is really too good and work with structure and template so powerful!!!!!

@@@is there any query regarding this post then post here i will replay as soon as possible@@@

getting images from document and media folder using structure and template

Finally i succeed to get images from document and media folder and this is code for that

#set ($DLAppServiceUtil = $serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLAppService"))
#set ($symbolsFolder = $DLAppServiceUtil.getFolder($getterUtil.getLong($groupId),0,"$foldername.getData()"))
#set($gid = $getterUtil.getLong($request.get("theme-display").get("scope-group-id")))

#if($symbolsFolder)
#set ($symbolImages = $DLAppServiceUtil.getFileEntries($getterUtil.getLong($symbolsFolder.getRepositoryId()),$getterUtil.getLong($symbolsFolder.getFolderId())))
<div id="gallery1" class="gallery" style="width:$w;">
#foreach( $symbol in $symbolImages )
<ul> 
#set ($dlService = $serviceLocator.findService("com.liferay.portlet.documentlibrary.service.DLFileEntryLocalService"))
#set ($dlfile = $dlService.getFileEntryByUuidAndGroupId($symbol.getUuid(),$gid))
#set ($filename = $dlfile.getName())



<a href="/documents/$symbolsFolder.getRepositoryId()/$getterUtil.getLong($symbolsFolder.getFolderId())/$dlfile.getName()/$symbol.getUuid()">
<li >
<img class="picture" src="/documents/$symbolsFolder.getRepositoryId()/$getterUtil.getLong($symbolsFolder.getFolderId())/$dlfile.getName()/$symbol.getUuid()""/>
</li > </a> 
<li class="imgtitle">
</li>

</ul>

#end
</div>
#else
No images in folder "$foldername.getData()"
#end

How to obtain the user id of visited user profile ?

Using velocity Template in liferay

Template Code:

#set($groupLocalService =
$serviceLocator.findExceptionSafeService("com.liferay.portal.service.GroupLocalService"))
#set($group =
$groupLocalService.getGroup($getterUtil.getLong($groupId))) ##
$groupId is already available in the context

#if ($group.isUser())
#set($userLocalService =
$serviceLocator.findExceptionSafeService("com.liferay.portal.service.UserLocalService"))
#set($user = $userLocalService.getUserById($group.getClassPK()))
#set($name = $user.getFullName())
#else if ($group.isOrganization())
#set($orgLocalService =
$serviceLocator.findExceptionSafeService("com.liferay.portal.service.OrganizationLocalService"))
#set($org = $orgLocalService.getOrganization($group.getClassPK()))
#set($name = $org.getName())
#else
#set($name = $group.getName())
#end

Google WebMaster tool in liferay


For Better SEO  for your website register your site in google webmaster tools.
To Register your site in Webmaster tools Follow Steps:
!)  sign up /sign in at http://google.com/webmasters/tools
2) add your website
3) Now as shown in below screenshot it will ask to verify ownership of website by  giving a html file to be uploaded on your Website in <HEAD> tag.Now as we have no server access to upload this file in root directory.So to get rid of this problem we have to first download that html file and upload that file in document library in liferay 6.0 as well as in 6.1.x in document and media.
4) After uploading a file ,Create a new page with name, same as  the file name you uploaded with given extension as shown in below screenshot
5) As shown above ,select the page type to be"URL"
6) In URL field add the url from the document library where you uploaded the html file.
7) And your site is registered in google webmaster tools.

Make Video Page Look Like Youtube Using Structure and template


Hello Guys 
For That We have To make two structure abnd template 
One For Add Video And Another is for Display Video
1) addVideo Strucutre and template
open Youtube and copy video url which you want to add and paste in textbox in structure then publish
Structure for add video
Template Code For add Video

#set($foo=$Video-URL.getData())
#set($n=$foo.split("v=").get(1))
<div id="web-video">
<iframe width="500" height="300" src="http://www.youtube.com/embed/$n?feature=player_detailpage" frameborder="0" allowfullscreen></iframe>
</div>
<div id="video-discription">
$Discription.getData()
</div>
2)  Display all Video using company id
Only Template is require to display video ,so used blank structure .
Template code:
#set ($journalArticleLocalService = $serviceLocator.findService('com.liferay.portlet.journal.service.JournalArticleLocalService'))
#set ($UserLocalService = $serviceLocator.findService('com.liferay.portal.service.UserLocalService'))
#set ($companyId = $getterUtil.getLong($request.theme-display.company-id))
#set ($curArticle = $journalArticleLocalService.getCompanyArticles($companyId,0,-1,-1))
#set($arc=$journalArticleLocalService.getCompanyArticlesCount($companyId,0))
#set ($ExpandoValueService= $serviceLocator.findService("com.liferay.portlet.expando.service.ExpandoValueLocalService"))
#set ($targetPortletID = "56")
 <div  class="video-list">
<ul>
#set ($counter = 0)
#set($by=10)
#foreach ($article in $curArticle)
#set($arc = $arc - 1)
#set($article=$curArticle.get($arc))
#if($journalArticleLocalService.isLatestVersion($article.getGroupId(),$article.articleId,$article.getVersion()))
#set ($articleUrl = "/widget/videos/-/journal_content/" + $targetPortletID + "/" + $article.groupId +  "/" + $article.articleId)
#set ($document = $saxReaderUtil.read($article.getContent()))
#set ($title = $document.valueOf("//dynamic-element[@name='Video-URL']/dynamic-content/text()"))
#if($title!="")
#set($n=$title.split("v=").get(1))
#set($userx = $UserLocalService.getUser($article.getUserId()))  
#set($Degree=$ExpandoValueService.getValue($companyId,"com.liferay.portal.model.User","CUSTOM_FIELDS","Degree",$article.getUserId()))
#set($Specialty=$ExpandoValueService.getValue($companyId,"com.liferay.portal.model.User","CUSTOM_FIELDS","Specialty",$article.getUserId()))
#set($Prefix=$ExpandoValueService.getValue($companyId,"com.liferay.portal.model.User","CUSTOM_FIELDS","Prefix",$article.getUserId()))
 <li class="videoli" style="list-style: none;width:330px;border-bottom: 1px solid #DDD;min-height:150px;">   
 <a href="${articleUrl}" target="video"><img src="http://img.youtube.com/vi/$n/default.jpg" style="float: left;
padding-right: 20px;
width:140px;"></a>
     <h4> $article.getUrlTitle() </h4>
     <a href = "/web/$userx.getScreenName()">
     $userx.getFirstName() $userx.getLastName()  </a> </br>
     $Degree.getData() </br>
     $Specialty.getData()
     
  </li> 
#set ($counter = $counter + 1)
#if($counter==$by)
  #if($by>50)
   #break
  #end
  @page_break@
#set($by=$counter+2)
#end
#end
#end
#end
</ul>
I implemented this code at http://liferay.medicalassociation.in/videos  Visit For Better Understanding .