1

I'm very new to Alfresco. My question is, how can we use a dashlet (created from scratch) into a page (created from scratch too)? What are the files and configurations to deal with, for including a dashlet into a page.

Moreover, the newly created page has to be similar to dashboard page but without authentication. The idea here is to do away from the default "Share" dashboard login flow.

Thanks.

  • I have written an answer to how to create a non-auth page. But maybe you would have an easier way by using a little bit of javascript that would auto-authenticate user as guest or something. As an authenticated user you have access to so much more - sites, search stuff, a lot really. You could even hide the "account" functions from the interface if that's also in the way. – Zlatko Jan 25 '13 at 23:07

3 Answers3

2

A dashlet is simply a special type of web script, so yes, it is quite possible to place the same web script into a custom page by binding it into a component region.

The relationship between pages, templates, components and regions can be a little complex if you're new to Share development, so I'd recommend reviewing Dave Draper and Erik Winlof's Share Customizations Live presentation from last November's DevCon, where they introduce a sample project including an Ant build script and which includes a custom web script and page definition. The code can be downloaded from this Git repo as a basis for your own project.

You should not find that too many changes if any are required to your dashlet web script to make it work inside a custom page, but remember that if the user is unauthenticated then you will not have access to any information about them, nor will you be able to retrieve any data from the repository.

Will Abson
  • 1,562
  • 7
  • 13
2

Let me try to answer this with some examples:

Alfresco page

To create an Alfresco Share page (you use share?), you need to create three files:

<TOMCAT>/webapps/share/WEB-INF/classes/alfresco/site-data/pages/my-page.xml
<TOMCAT>/webapps/share/WEB-INF/classes/alfresco/site-data/template-instances/my-page.xml
<TOMCAT>/webapps/share/WEB-INF/classes/alfresco/templates/org/alfresco/my-page.ftl

The first one defines your page, the second one defines what components (dashlets) you will use on the page, and the last one is a HTML template (in Freemarker) arranging your components.

The first two files are XML, a bit alfresco specific, but simple XML, and the last one you could put static HTML and it'd work, or you could put some freemarker macros. What is in each of those files (examples), you can read on this page, written specially for you and this question :) (Don't ask, I felt like writing about it)

No authentication

To not use authentication, you can just put <authentication>none</authentication> in the page definition file (the first XML file).

Dashlet files

Basically, a dashlet can be at the minimum two files, usually 4-5 or something like that. The dashlet.get.desc.xml file signifies two things: desc.xml part says it's for a new component (dashlet), and get part says this component will answer to HTTP GET calls. is usually placed somewhere bellow /webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/components. Doesn't really matter where bellow, but you would want to put it in some folder to manage all your code easier. This file contains one important thing: url. Url defines what url your dashlet will answer to. And when you defined your page in the page definition above, you would put this url there to access the dashlet.

You could even access the dashlet directly, using the link http://localhost:8080/share/my/url/to/dashlet.

The other file, dashlet.get.html.ftl is, again, a freemarker template file. You put HTML there. You can also have a controller file for the dashlet, dashlet.get.js which prepares some dynamic content (it is written in server-side javascript and has access to some of Alfresco Javascript API).

Finally, you can put some internationalized text (translations) into bundles (basically, dashlet.get.properties, dashlet.get_DE.properties, dashlet.get_ES.properties etc, by browser lanugages).

There are also options to include client-side javascript or css files to this dashlet.

To see how exactly to assemble all this, you could try reading this page. Probably not really a good read, but it will hopefully clear some things up.

Zlatko
  • 18,936
  • 14
  • 70
  • 123
  • sure you could do that, my statement was about using webscripts with root objects or something similar. You can actually create a webscript in alfresco/share with authentication none, but you cannot access any of the content/root objects/actions/rules etc. Depends on what do you need in the webscript to be displayed. – Teqnology Jan 26 '13 at 22:38
  • 1
    This is exactly how a beginners book should explain the mandatory page creation components – Dark Star1 Mar 18 '13 at 03:34
  • From beginners to beginners :) – Zlatko Mar 19 '13 at 08:15
1

Sorry, just to be clear, you want to reproduce a share interface on an Alfresco repository, but without the login? Dashlets and interface components are webscripts, and webscripts are stored inside the repository, so in order to access them you need to be authenticated. You could use tag in the webscript xml description a runas="admin" or runas="guest" in order to achieve something. If i misunderstood, please let me know, and I'll try to help..

Teqnology
  • 1,282
  • 8
  • 20
  • This is not entirely correct. You can use share pages and dashlets without authentication, wait for my blog post and upcoming answer :) – Zlatko Jan 25 '13 at 22:14
  • Or wait, did the OP want it on /alfresco? You can still access webscripts as authentication=none, no issues there, you can even none to access protected data, correct? – Zlatko Jan 25 '13 at 22:46