Redirect Settings Action

First steps

First you want to derive your new class from NormalSettingsActions as in the code example below.

CopyC#
public class GotoFolioIndex : RedirectSettingsAction
{

    public override string Label
    {
        get { throw new NotImplementedException(); }
    }

    public override bool CanPerformAction(SettingsViewType viewType, string objectType, IFolio folio, ISiteManager sm)
    {
        throw new NotImplementedException();
    }

    public override string GetRedirectUrl(Func<string, string, object, string> actionControllerInfoToUrl, string objId, SettingsViewType viewType, string objectType, IFolio folio)
    {
        throw new NotImplementedException();
    }
}

These are the functions that must be defined for it to compile and be a fully functional Settings Action

API Reference

  • Label: This is the friendly name displayed to the user in the action drop down menu.

  • CanPerformAction: This returns whether the action can be done in the current area of the admin interface.

  • GetRedirectUrl: This returns the URL that the action should redirect to. The actionControllerInfoToUrl parameter is a function that takes a action name, controller name, and route values and is basically a light wrapper around the MVC Url class. This allows you to get the URLs to routes within Cartella.

Example

Here is a fully functional custom Redirect Settings Action

CopyC#
public class GotoFolioIndex : RedirectSettingsAction
{
    // Friendly Name of the action
    public override string Label
    {
        get { return "Goto Folio"; }
    }

    //Whther the action can be displayed and done
    public override bool CanPerformAction(SettingsViewType viewType, string objectType, IFolio folio, ISiteManager sm)
    {
        return viewType == SettingsViewType.normal &&
            SettingsUtility.GetSettingEnum(objectType) == SettingsTypes.Folio;
    }

    //returns the redirection URL
    public override string GetRedirectUrl(Func<string, string, object, string> actionControllerInfoToUrl, string objId, SettingsViewType viewType, string objectType, IFolio folio)
    {
        string action = "Index";
        string controller = "Folio";
        object routeValues = new {folioID = objId };
        return actionControllerInfoToUrl(action, controller, routeValues);
    }
}