Documentation

Custom card view model

The view model is an object available in every template. It is a simple object with properties that describe the current state of the page running the template.

Properties


CustomPortletUniqueId

Syntax:

public string CustomPortletUniqueId { get; set; }

Return value:

Type Description
string The unique id of this instance of the custom card (e.g. CustomPortlet_Center_1_2972_5111 

Examples:

@this.Model.CustomPortletUniqueId

Configuration

This returns the JSON configuration string for the custom card. This can be used to pass in variables and objects upon initialization of the custom card instance. 

Syntax:

public string Configuration { get; set; }

Return value:

Type Description
string The JSON configuration object as a string for the current card.

Examples:

@this.Model.Configuration 

Context

See the page Core object model for details. 

Syntax:

public IPageContext Context { get; set; }

Return value:

Type Description
IPageContext The IPageContext object for the current user, page and session.

Examples:

@this.Model.Context 

CurrentUserCanEditThisContent

Syntax:

public bool CurrentUserCanEditThisContent { get; set; }

Return value:

Type Description
bool True if the user can edit the page the card is running on. False otherwise

Examples:

@this.Model.CurrentUserCanEditThisContent

CurrentContentIsCurrentUsersPlace

Syntax:

public bool CurrentContentIsCurrentUsersPlace{ get; set; }

Return value:

Type Description
bool True if this page is the current user's profile page. False otherwise

Examples:

@this.Model.CurrentContentIsCurrentUsersPlace



Methods


GetConfiguration

This returns a Dictionary of all the <string, object > items for the custom card. This can be used to get the variables and objects upon initialization of the custom card instance. 

Syntax:

public Dictionary<string, object> GetConfiguration()

Return value:

Type Description
Dictionary<string, object>
The configuration json string as a dictionary

Examples:

@{
    var configuration = this.Model.GetConfiguration() ?? new Dictionary<string,object>();

int customInt = 0; // default value
if(configuration.ContainsKey("customInt"))
{
    customInt = Convert.ToInt32(configuration["customInt"]);
}

}