Kentico CMS 7.0 Developer's Guide

Overview

Overview

Previous topic Next topic Mail us feedback on this topic!  

Overview

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

Macros are strings that are automatically resolved into their value equivalents. They represent a powerful option that can often eliminate writing custom .NET code.

 

There are several types of macros, all of which are listed and explained in the Types of macros topic. The most powerful are context macros, using which you can achieve most of the results achievable by using all other types of macros. Context macros can contain advanced expressions written in the K# language, whose syntax and features are described in the K# syntax topic. Methods that can be used in K# are listed and described in the Available macro methods topic. Macro parameters known from older versions of Kentico CMS are still functional and available, even though the same results can now usually be achieved through macro methods.

 

The user interface of Kentico CMS has several built-in features which facilitate entering of macro expressions. These are explained in the Entering macro expressions topic.

 

One of the ways to leverage macros is defining dynamic conditions for various types of functionality. There are several features available that make it easier to build such conditions. It is even possible to prepare components that allow users to work with conditions without any knowledge of the macro syntax. Please see the Macro conditions topic to learn more.

 

When certain macros are resolved, security checks are performed to verify that the user who entered the expression has permissions to read the resolved data. These checks are covered in the Macro security topic.

 

The default functionality of the macro engine can be enhanced by your custom code. It is possible to define custom macro methods and use them in macro expressions along with the default ones. The process of creating such methods is described in the Registering custom macro methods topic. Additionally, macro expressions can be resolved in your custom code using the API, and it is even possible to customize macro resolvers. This is described in the Resolving macros using the API topic.

 

For performance reasons, the system also provides a way to cache the values of resolved macros, so that certain macros do not need to be resolved repeatedly. More information on this can be found in the Macro result caching topic.