Wednesday 24 April 2013

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 .

No comments:

Post a Comment