Presentation is loading. Please wait.

Presentation is loading. Please wait.

Macros in action Martin Hejtmanek CTO, Kentico software s.r.o.

Similar presentations


Presentation on theme: "Macros in action Martin Hejtmanek CTO, Kentico software s.r.o."— Presentation transcript:

1 Macros in action Martin Hejtmanek CTO, Kentico software s.r.o.

2 Agenda History of macros Macro types Macro parameters Examples, tips and tricks Custom macros Nested macros Future of macros

3 What is a macro? Macro in Kentico CMS: – “Abstraction of the code that can be replaced by dynamic or context specific value on-the-fly without compilation.” Reasons: – Security – Limited set of data, read only – Practical – Injecting dynamic values into plain text without coding Conclusion: – “Each day, the macros prove that they are the right way to go” – “Macros have future”

4 History of macros V 1.x – Only ASPX templates, everything dynamic done via CodeBehind – Only hardcoded macros in queries or e-mail templates ##WHERE##, {%useremail%} V 2.0 – Portal engine – How to dynamically populate web part parameters without giving the user access to the code? V 2.3 – MacroResolver + first macro types (localization, data & context, query string, cookie) – Allowed parametrization of where conditions (text properties) from query string or context e.g. “NewsID = {?newsid?}”

5 History of macros V 3.0 – Path & Custom macros, Path expressions – Dynamic context-based paths, custom logic V 4.0 – Change to the UI – Dynamic non-text properties – Macro parameters {?username|(equals)administrator?}, {?newsid|(toint)?} V 5.5 – Macro debug, more parameters

6 Macro types Data & Context – {%DocumentName%} QueryString – {?myvalue?} Localization – {$resourcekey$} In-place localization – {$=Hello|cs-cz=Ahoj$} Path – {&/{0}/Teaser&} Cookie – {@cookiename@} Custom – {#expression#}

7 Macro parameters Syntax – {%expression|(param1)value1|(param2)value2%} Modification or evaluation of the macro result – Ensuring type safety – {?newsid|(toint)?} – Boolean expressions – {%UserName|(equals)administrator%} – Mathematical functions – {%SKUPrice|(multiply)0.8%} – Processing flags – {%CurrentUser.FullName|(encode)true%}

8 Examples Dynamically populated texts Localization Controlling the visibility of a web part Where conditions based on query string Providing dynamic CSS styles (color profiles)

9 Custom macros {#expression#} Most powerful ones Your own code ~/App_Code/Global/CMS/CMSCustom.cs public static string ResolveCustomMacro(sender, expression, out match) { // Your code }

10 Nested macros Macros may be recursive (not query string, not cookies) Recursion is applied on the result – {?name|(equals){%UserName%}?} – Not possible (yet) – Request.QueryString[“name”] == “{%UserName%}” Same types of macros nested – {%UserName|(equals)admin|(truevalue)Admin|(falsevalue){%FullName%}%} – Is the end of the macro first %} or second? Paired – {(1)%UserName|(equals)admin|(truevalue)Admin|(falsevalue){(2)%FullName%(2)}%(1)} – The end has the same number as the start

11 Future of macros V 6.0 ?? – Unification {%QueryString.MyParam%}, {%Cookies.MyCookie%}, … – Structured values (object hierarchy) {%CurrentDocument.Parent.Owner.FullName%} – Collections {%CurrentDocument.Children[2].DocumentName%} – C# like expressions in macros {% (UserName == “administrator”) && (QueryString.NewsID == 123) %} {% CurrentDocument.GetImage(“MyField”) %}

12 Summary History of macros Macro types Macro parameters Examples, tips and tricks Custom macros Nested macros Future of macros

13 Sources of information Kentico CMS 5.5 Macro reference (poster) Developer’s guide – http://devnet.kentico.com/docs/devguide/index.html?appendix_a___macro_expressions.htm http://devnet.kentico.com/docs/devguide/index.html?appendix_a___macro_expressions.htm Blog – http://devnet.kentico.com/Blogs/Martin-Hejtmanek/June-2010/New-in-5-5--Macro-parameters.aspx http://devnet.kentico.com/Blogs/Martin-Hejtmanek/June-2010/New-in-5-5--Macro-parameters.aspx E-mail – support@kentico.com support@kentico.com – martinh@kentico.com martinh@kentico.com


Download ppt "Macros in action Martin Hejtmanek CTO, Kentico software s.r.o."

Similar presentations


Ads by Google