Friday, January 13, 2012

Create custom dashlet in alfresco share.



Creating Custom Dashlet

creating custom dashlet is easy in alfresco share. Most common required file(s) are as below:
  1. descriptor file (.desc.xml)
  2. main html template file (.html.ftl)
  3. js file (having logic for calling local or remote script) [optional]
  4. properties file [optional]
  5. head file [optional]
    Let we will create sample dashlet which will display current user name who logged in.

For the starting point lets create these files in Out-of-box path :
alfresco\tomcat\webapps\share\WEB-INF\classes\alfresco\site-webscripts\org\alfresco\components\dashlets

  • loggeduser.get.desc.xml

This file is descriptor file and define a webscript url through which it will be called and display appropriate template.


<webscript>
<shortname>Username Display Dashlet</shortname>
<description>Demo dashlet for username display</description>
<family>site-dashlet</family>
<url>/components/dashlets/loggeduser</url>
</webscript>

  • loggeduser.get.html.ftl
This file is html template or display area of the script. Content would be displayed here.
<div class="dashlet">
<div class="title">Demo</div>
 <h3> Logged user : ${user.name}</h3>
</div>



Now check with your site dashboard area and click “customize dashboard” button and select dashlet Username Display Dashlet.

Click “OK”

done...!!!

8 comments:

  1. simple and very helpful! think you

    ReplyDelete
  2. after adding this 2 files to the specified path and restarting alfresco i still couldn't find the dashlet

    ReplyDelete
    Replies
    1. Hope you adding your dashlet from customize dashboard button.

      Delete
  3. Please try again and make sure the given path is perfect. It should work.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. I am new to Alfresco, Where I can get the all the property values like ${user.name}. means If I need the user location to display, then where can I get to know that there is a property value for location.?

    ReplyDelete
    Replies
    1. Siddharth,

      What mean you want user location ? you can get reference from : http://wiki.alfresco.com/wiki/3.0_JavaScript_API
      There are few public API available for JS.

      Delete