In this blog post, we review the steps for customizing StoreFront so that the user’s default landing page is dynamically determined based on the number of applications that user has favorited.

By default, on a user’s first login to StoreFront, they will land on an empty favorites page with a note directing them to the apps tab. But let’s face it, users aren’t always the most technically savvy folks. If they’re greeted by an empty favorites page, they might be inclined to call your company’s tech support team for help. You can avoid this by making StoreFront just a tiny bit more responsive.

Landing page with no favorites

This modification will work for both Receiver for Web and Receiver for Windows and has been validated with StoreFront 3.6, 3.9 and 3.12, and 1903.1.0, but should work with other versions, as well. It requires JavaScript to implement.

There are a variety of different ways to achieve the same result, but here is one example we recently implemented with a customer. In this example, the applications tab is the default landing page until the user has favorited at least one application. At that point, the default becomes the favorites page. Applications published as mandatory are ignored (i.e. applications that users cannot remove from their favorites are not counted).

Step 1: Add code to script.js
Within Windows Explorer on the primary StoreFront server, navigate to the following path:

[Drive Letter]:\inetpub\wwwroot\Citrix\[Store Name]Web\custom

For example:
C:\inetpub\wwwroot\Citrix\TestStoreWeb\custom

Create a backup of script.js and open in Notepad as an administrator.

Note: If you plan on making a lot of changes to this file, it would be beneficial to add your domain user account to the security properties of the file and give yourself full control. That way, in the future, you can just open the file by double clicking it instead of using an elevated notepad.

Add the following content to the bottom of this file:

//If favorites exist, go to favorites tab. If favorites do not exist, go to the store tab.
var favoritesExist = false;

CTXS.Extensions.sortMyAppList = function (app_array,defaultSortFn) {
//This version checks if the amount of user favorites are greater than or equal
//to "favoriteThreshold".
  var favoriteThreshold = 1;
  var favoriteCount = 0;
  for (var i = 0; i < app_array.length; i++){
    if (app_array[i].canBeRemoved()){
      favoriteCount++;
    }
  } 

  if (favoriteCount >= favoriteThreshold){
    favoritesExist = true;
  }

  //This should always be called at the end
  defaultSortFn();
};

CTXS.Extensions.afterDisplayHomeScreen = function (callback) {
  if (favoritesExist == false){
    CTXS.ExtensionAPI.changeView("store");
  }
};

Step 2: Modify threshold
Find the following line:
var favoriteThreshold = 1;

Adjust the threshold to a value of your choosing.

Step 3 (Optional): What if you’ve disabled the apps tab and only have desktops?
In this scenario, simply edit the changeView command to direct users to the desktops tab instead of the apps tab. The code for this is below:

CTXS.Extensions.afterDisplayHomeScreen = function (callback) {
  if (favoritesExist == false){
    CTXS.ExtensionAPI.changeView("desktops");
  }
};

Step 4: Propagate your changes
Now that the changes are implemented on your primary StoreFront server, navigate to the Server Group tab and click Propagate Changes. This will pause your server group and replicate the customizations to the other servers in the group (users will not be able to connect during propagation, so be sure to do this only during off-hours).

Want More Customizations?

This post is part of a StoreFront customization series. For more step-by-step guides on customizing StoreFront, check out the entire series here (we’ll update that post as more items are added to the series).


Citrix Tech Bytes – Created by Citrix Experts, made for Citrix Technologists! Learn from passionate Citrix Experts and gain technical insights into the latest Citrix Technologies.

Click here for more Tech Bytes and subscribe.

Want specific Tech Bytes? Let us know! tech-content-feedback@citrix.com.