Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Creating Custom Reports View modes: 
User avatar
Member
Member
admin-hin.com - 11/16/2011 3:25:34 AM
   
Creating Custom Reports
G'day,

Where can i learn more about creatining custom reports. I know where to find them in the cms, how to create them but don't understand how to create the macros.

The first one I want to create is a report that tells me Documents created by each owner, in other words which user created documents or actually how many documents each user owns/created.

I'd like to run a reward program.

Any help appreciatted.

Cheers

P.S. I've already poured over the documentation and googled it, but unless someone has already created the macro I actually need to understand it.

User avatar
Kentico Support
Kentico Support
kentico_janh - 11/16/2011 5:20:27 AM
   
RE:Creating Custom Reports
Hello,

You can define your own macro. The macro is in the {% ProcessCustomMacro("Expression", "") %} format. When the macro is needed to be resolved, it calls the ResolveCustomMacro method located in the ~/App_Code/Global/CMS/CMSCustom.cs class (or ~/Old_App_Code/Global/CMS/CMSCustom.cs if you installed the project as a web application).

Example: “Current time: {% ProcessCustomMacro("CurrentTime", "") %}” will be resolved to “Current time: 1/1/2008 10:30“ with following custom macro handler:

/// <summary>
/// Custom macro handler
/// </summary>
/// <param name="sender">Sender (active macro resolver)</param>
/// <param name="expression">Expression to resolve</param>
/// <param name="match">Returns true if the macro matches (was resolved)</param>

public static string ResolveCustomMacro(MacroResolver sender, string expression, out bool match)
{
match = false;
string result = expression;

// Add your custom macro evaluation
switch (expression.ToLower())
{

case "currenttime":
match = true;
result = DateTime.Now.ToString();
break;

}

return result;

}

Best regards,
Jan Hermann