While working in
Alfresco and getting to know more and more about Alfresco, I have
found it really amazing how Alfresco has developed over the years.
One of the requirements that I was working on during one of the
projects was to customize the dashboard layouts of all the existing
users and the existing sites. To be specific, my requirement was to
change the dashboard layout of all the existing users and all the
existing sites to a 3- column layout.
Moreover, in case of
the user dashboard, the 3rd column had to be fixed with
two particular dashlets for all the users such that the users cannot
add or change dashlets in the third column neither can they change
their dashboard layout. In case of the site dashboard, the first
column had to be fixed with two particular dashlets such that the
site manager cannot add or change the dashlets in the first column
neither can they change the dashboard layout of that site. And there
were some 8000 users and 300 sites in the system.
To set the dashboard
layout and dashlets in specific columns for new users and new
sites, we can do the desired changes in the presets.xml file. But to do changes for the existing users and the existing sites is not that
easy. One of the ways to achieve this is through FTP.
The basic thought of
customizing the dashboard layout of the existing users and sites was
that there must be a file that has the details of the dashboard
layouts and dashlets to be called when the dashboard is loaded for
the first time. If we are able to let alfresco ignore that file and
use the settings defined in presets.xml file then our work is easily
done. We can define our desired dashboard layouts and desired
dashlets in the presets.xml file and then somehow call this file for
all the existing users and all the existing sites.
Well, the file which
holds the details of the dashboard layouts for the existing users and
the existing sites is dashboard.xml and this file can be accessed via
ftp through AVM.
Here is how you can do
it. First lets see how we can customize the dashboard layout for the
existing USERS:
____________________________________________________________
1. Set up an FTP
connection.
2. To enable FTP go to
file-servers.properties file in
{Tomcat-Home}\webapps\alfresco\WEB-INF\classes\alfresco\subsystems\fileServers\default.
3. Open the
file-servers.properties file, set ftp.enabled=true and save it.
4. Open Command Prompt.
5. Type ftp
{server-name} [for eg:- ftp localhost] and press enter.
6. Enter the username
and password for the administrator account.
7. Open My Computer.
8. In the address bar,
type ftp://{server-name} [for eg:- ftp://localhost ] and press enter.
9. Enter the
credentials for administrator account.
10.Open location
ftp://{server-name}/AVM/sitestore/HEAD/DATA/alfresco/site-data/pages/user/
11.There you'll see
individual folders of every user.
12.BackUp and Delete
all the folders.
13.Restart the server.
14.Now the dashboard
layout and the dashlets will be imported from the presets.xml file.
____________________________________________________________
After following the
above steps, you will be able to set the dashboard layout and the
dashlets positions
as you have mentioned
in the presets.xml file for the user-dashboards.
Now lets see how we can
customize the dashboard layout for the existing SITES:
____________________________________________________________
1. Set up an FTP
connection.
2. To enable FTP go to
file-servers.properties file in
{Tomcat-Home}\webapps\alfresco\WEB-INF\classes\alfresco\subsystems\fileServers\default.
3. Open the
file-servers.properties file, set ftp.enabled=true and save it.
4. Open Command Prompt.
5. Type ftp
{server-name} [for eg:- ftp localhost] and press enter.
6. Enter the username
and password for the administrator account.
7. Open My Computer.
8. In the address bar,
type ftp://{server-name} [for eg:- ftp://localhost ] and press enter.
9. Enter the
credentials for administrator account.
10.Open location
ftp://{server-name}/AVM/sitestore/HEAD/DATA/alfresco/site-data/pages/site/
11.There you'll see
individual folders of every site.
12.BackUp and Delete
all the folders.
13.Restart the server.
14.Run the below
mentioned web script.
14.Now the dashboard
layout and the dashlets will be imported from the presets.xml file.
____________________________________________________________
enable-sites.js
function main()
{
var sites = null;
var result =
remote.call("/api/sites");
model.status = "fail";
if (result.status ==
200) {
sites = eval('(' +
result + ')');
var globalPreset =
"site-dashboard"; // sitePreset
var tokens = new
Array();
if(sites != null &&
sites.length > 0)
{
for(var i =0; i <
sites.length; i++)
{
tokens["siteid"]
= sites[i].shortName;
sitedata.newPreset(globalPreset,
tokens);
}
model.status = "ok";
}
}
}
main();
(This is just the
javascript code. Make the corresponding xml and ftl files to make it
a web script).
After following the
above steps, you will be able to set the dashboard layout and the
dashlets positions as you have mentioned in the presets.xml file for
the site-dashboards.
Before applying the
changes to all the users and sites, try to apply the change to a
single user dashboard and a single site dashboard.
Good blog dude. keep it up!
ReplyDeleteUnfortunately as Alfresco has decided to do away with the AVM in the future releases, this approach would only work for alfresco versions<4.0
ReplyDeleteI will soon write a blog on how we can customize existing dashboards in Alfresco 4.
ReplyDeleteWould be great also interested in it
DeleteCongratulations for your blog and such useful post. So there isn't any possible way to update the dashboard configuration (presets) of previously existing sites' on Alfresco 4 Perhaps have you found out how?
DeleteThanks.
Thank you and I am really happy that my blog was useful to you...
DeleteYes, there is, for sure, a way to do that. I am currently writing that....will post it over here soon...
Great to know it!!
DeleteIt would be nice to know if there exists any kind of limitation when updating old Alfresco Share Sites with new presets. The Share customization I'm currently developing will require several presets changes in the mid-term future. The custom preset is heavily customized as well because it is not only a custom preset, underlying template-instance and Freemarker template are also custom objects.
I'll be waiting for your post anxiously :)
It's fine, but site dashboard not working after Tomcat Restart. Can you help me to solve this issue?
ReplyDeleteHi,
ReplyDeleteWhat is the error you are getting? I believe you need to run "enable-sites.js" to make sure your site dashboard starts working again.