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.