|
||
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 versions of Kentico CMS prior to 6.0 are still functional and available, even though the same results can now be achieved using the 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. 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. At first, it is possible to define custom macro methods and use them in macro expressions along with the default ones. A step‑by‑step process of creation of such methods is described in the Registering custom macro methods topic. It is also possible to cache values of resolved macros in order for certain macros not to be resolved repeatedly. More information on this can be found in the Macro result caching topic. Finally, macro expressions can be resolved in your custom code, while it is even possible to define your custom macro resolvers and resolve macros using them. This is described in the Resolving macros using API topic.