August 4, 2015 Development Tips

Tutorial on Kentico Macros

By: Laura Frese
Kentico has a plethora of features available to make creating and editing sites easier and faster. In this post I will review the macro autocomplete feature, a shortcut for inserting macros into fields & text areas, and the various places you can use macros.

In editable text areas on the Page view tab you can view a list of macro options by clicking on the insert macro icon {#}.

Macro Icon

This will open the Insert Macro dialog which shows a tree listing available options. 

Macro Option Tree

In addition, by clicking the code tab you can write the macro expression and take advantage of the autocomplete feature. If the autocomplete disappears or doesn’t open automatically, try pressing Ctrl + Shift + Space.

Macro Autocomplete

The macro can be manipulated using operators, methods, conditions, iterations and entered inline with the rest of the content in the editable region

Inline Macro

Macros can also be used in areas where the Macro Arrow icon is present. This includes web parts and default form field values.

For example, a macro can be used to get a dynamic value to set the visibility of a web part:

Kentico Web Part Visibility

Or to grab a parameter from the url to create a dynamic where condition:

Macro Where Query
You can learn more about Macros in the kentico documentation:
Entering Macro Expressions
Macro Syntax