Select Category And add Post in message board using velocity template

General Blogs May 7, 2013 By chirag @ India

Hi Guys,

It is possible to put web content of MB-category in every page rather than to display message board in every page in website .

On selecting category, we will open a pop-up dialog box for inserting  Post in message board. 

Template Code :

 

#set ($MBLocalService= $serviceLocator.findService("com.liferay.portlet.messageboards.service.MBCategoryLocalService"))
 
#set($cat=$MBLocalService.getCategories($groupId))
 
<form name="frmmb" id="frmmb">
<select name="foo" id="foo" onchange="pop(this.value)">
<option  value= "select">  -select-- </option> 
#foreach ( $c in $cat)
<option  value= "$c.getCategoryId()">  $c.getName() </option> 
 
#end
</select>
</form>
<script type="text/javascript" charset="utf-8">  
  
function pop(value)
{
var s=value;
alert(s);
 AUI().ready('aui-dialog','aui-dialog-iframe','liferay-portlet-url', function(A) {     
    var url = Liferay.PortletURL.createRenderURL();      
   url.setPortletId("19");        
 url.setWindowState('pop_up');           
 
url.setParameter("&_19_struts_action=%2Fmessage_boards%2Fedit_message&_19_mbCategoryId=");
  window.myDialog = new A.Dialog(             {               
  title: 'Ask a Question?',   
              width: 640,           
      centered: true            
 }         ).
         plug(          
   A.Plugin.DialogIframe,             {               
  uri: url.toString()+""+s,               
  iframeCssClass: 'dialog-iframe'             }  
       ).render();     }); 
}
 
</script>
<input type="button"  class="aui-button-input aui-button-input-submit"  name="dialog" value="Select Catagory & Add Question" />

 

I implemented this code at http://liferay.medicalassociation.in/ask-question  Visit For Better Understanding .

Make Video Page Look Like Youtube Using Structure and template

General Blogs April 23, 2013 By chirag @ India

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 medicalassociation.in/videos  Visit For Better Understanding .
 
 
 
 
 

Google WebMaster tool in liferay

General Blogs April 18, 2013 By chirag @ India

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.

Showing 3 results.