Skip to content

Global Attributes

nairdo edited this page Oct 25, 2012 · 8 revisions

Rock has a place where your custom blocks and other code (Jobs, Transactions, etc.) can access globally configured setting values. To retrieve a value, use the Rock.Web.Cache.GlobalAttributes.Read().GetValue(string attributeKey) method as seen here:

    var cache = Rock.Web.Cache.GlobalAttributesCache.Read();

    // determine if 404's should be tracked as exceptions
    bool track404 = Convert.ToBoolean( cache.GetValue( "Log404AsException" ) );

MERGE FIELDS

The _values _of global attributes can also have merge fields in them that contain _other _global attributes. For example, say you are working on an email templates and several of the templates should have the same header and footer (common for styling). These headers and footers however may have settings in them like the background color or logo url. This is all possible with 'global attribute nesting'. The 'header' attribute can include the 'background-color' attribute and be used in the email template. This nesting can be n levels deep, however, simpler is better. The administrator must be very careful to not create circular references (A includes B which includes A) as these will cause the system to enter a loop and cause it to run out of memory.

Clone this wiki locally