Tuesday, January 31, 2017

How to Change the Alfresco Share Landing Page for all Users

In Alfresco 5.1.x, it’s easy for users to change their own home page. The Use Current Page option in the user menu can be used to change the logged in user’s home page to the current page. And, the home page can also be reset back to the user’s dashboard with the selection of the Use My Dashboard option.

But, what if you want all of your Alfresco users to use the same landing page when they log in to Alfresco Share? Perhaps you’d like it to be your corporate site dashboard or a heavily-used site folder? Instead of having your users individually change their home page, an admin user can easily make a global change for all users like this:
1.      Open the TOMCAT/webapps/share/site-index.jsp file for editing.

a.       Look for the following lines at the bottom of the file:

    // redirect to site or user dashboard as appropriate
     String siteName = request.getParameter("site");
        if (siteName == null || siteName.length() == 0)
        // Get and forward to user's home page
        SlingshotUserFactory slingshotUserFactory =
                (SlingshotUserFactory) FrameworkUtil.getServiceRegistry().getUserFactory();
        String userHomePage = slingshotUserFactory.getUserHomePage(context, userid);
        response.sendRedirect(request.getContextPath() + userHomePage);
        // forward to site specific dashboard page
        response.sendRedirect(request.getContextPath() + "/page/site/" + URLEncoder.encode(siteName) +  "/dashboard");

b.      Set the "siteName" variable to your preferred landing page site name, for example:

  String siteName = request.getParameter("site");
     siteName = "formtek";

      c.       If you want your site dashboard to be the new landing page, you’re done editing the file.                        However, if you want your new landing page to be a folder in your site, you’ll need to make                  one more change to replace “dashboard” in the following line with the document library                        folder of  your choice:

 response.sendRedirect(request.getContextPath() + "/page/site/" +    URLEncoder.encode(siteName) + "/dashboard");

In this example, I’m using the “Policies and Procedures” folder in the site’s document library:

 response.sendRedirect(request.getContextPath() + "/page/site/" +  URLEncoder.encode(siteName) +  "/documentlibrary#filter=path%7C%2FPolicies%2520and%2520Procedures%7C&page=1");

NOTE: To get the correct folder syntax, you can navigate to the folder in Alfresco Share and copy the folder syntax from the browser address bar.

d.      Save your changes and close the file.

2.      Restart Alfresco for the changes to take effect.

Now, when a user logs in to Alfresco Share, the user will be redirected to your newly configured landing page. Here are two different results for the above examples:

The configured site dashboard is the new landing page:

The configured site folder is the new landing page:

It is important to note that if your new landing page restricts site membership (as in the case of the “private” example site above), non-members would see the following upon login:

Clicking the “Back to My Dashboard” button redirects unprivileged users to their own home page. To eliminate this scenario, changes would need to be made to verify site membership and only redirect site members to the new landing page. (Perhaps the discussion of a future post.)

1 comment:

  1. I like the helpful info you provide in your articles. I will bookmark your blog and check again here regularly. I'm quite certain I will learn many new stuff right here! Best of luck for the next!
    Landing Page Design and Optimization * best web design services