Tuesday 7 May 2013

Select Category And add Post in message board using velocity template.


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 .

No comments:

Post a Comment