by dan
21. October 2009 22:10
Using AxCMS.net for sending out HTML mails like registration and / or activation everyone is able to understand what an macro is:
Macros are scripts that will be interpreted during rendering to show specific content to the end user. Mostly unknown is the fact that macros are supported in normal pages as well.
Using macros you are able to extend the editors possibilities for designing meaningful user interaction. Editors are no longer bound to use preformed controls to adress certain information. They can choose freely if and when to use the information at hand.
Lets take - for example - a web site in which article can be ordered. At any place the end user should be presented the number of articles in his shopping bag. Typically you fulfill this task using an dynamic control, which would force the editor to use this control whenever he wants to show the number of articles to the end user. When you create a macro like {[ArticleCount]} or - even better - {[ShoppingBag.ArticleCount]} you enable your editors to freely choose when and where to tell the user how much articles he has in his bag.
As the help files point out, there are several macro types to choose from:
- {̣[Property]}
this macro will be replaced with the properties value. It is the most common macro type. An example would be the well known macro of {[FullName]} that can be found in the PremiumSample ActivationMail.
public override string ActivationLink
{
get
{
string link = ...;
return "<a href=\"" + link + "\">" + link + "</a>";
}
}
- {̣[Object.Property]}
this macro will be replaced with the objects property value.
- {̣[Func()]}
this macro will be replaced with the result of calling the function named inside the macro value container. Even usable with string parameter types.
Additionally there are two objects you can always adress:
- {̣[@page.Property]}
this macro will be replaced with the current page property value
- {̣[@user.Property]}
this macro will replaced with the current user property value. (So {[FullName]} equals {[@user.FullName]}
Basically there is one easy way to decide if you should present information using a macro: If the information to be displayed should fit into free text flow use a macro.
Regards
Dan