Here is an example that I hope will help you (it is also available on the Wiki). Most of the magic happens in JavaScript (although the layout is also partially installed in html).
Suppose you want to create a dashlet. You have several files in the layout:
Server server components:
$TOMCAT_HOME/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components/dashlets/...
and client scripts are in
$TOMCAT_HOME/share/components/dashlets...
So, on the server side there is a dashlet.get.desc.xml file that defines the URL and describes the web page / dashlet.
There is also a dashlet.get.head.ftl file - here you can put <script src = "..."> tags and they will be included in the <head> component of the full page.
Finally, there is the dashlet.get.html.ftl file, which has the type <script type = "text / javascript"> tag, which usually initializes your JS, usually like the new Alfresco.MyDashlet (). setOptions ({...});
Now there is a client side. You have, as I said, the client side of the script in / share / components / dashlets / my-dashlet.js (or my-dashlet-min.js). This script usually contains a self-executing anonymous function that defines an Alfresco.MyDashlet object, something like this:
(function() { Alfresco.MyDashlet = function(htmlid) {
So now you have it. If you look at the alfresco.js file, you will learn about materials that you can use, for example, Alfresco.util.Ajax, createYUIButton, createYUIPanel, createYUIeverythingElse, etc. You can also learn a lot by trying to play, say, mine-sites or target-tasks, they are not so complicated.
And Alfresco will put your html.ftl part in the body of the page, your .head.ftl part in the page title, and the end user will load the page, which:
- loads the html part
- loads javascript and executes it
- javascript then takes care of loading other components and doing things
Try to get this and you can get other more complex stuff. (perhaps:))