Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Custom context macros View modes: 
User avatar
Member
Member
Brian.Kellogg-VinSolutions - 10/22/2012 4:12:40 PM
   
Custom context macros
Currently I'm able to create macros through the GlobalResolver by using this code in its own class in the App_Code folder:
public override void Init()
{
ContextResolver.GlobalResolver.SetNamedSourceDataCallback("SomeRandomMacro", SomeRandomMacro, false);
}
private object SomeRandomMacro(MacroResolver r)
{
return "blah logic stuffhere";
}

This will allow a user to see it in the macros screen as SomeRandomMacro, but I want to create my own context such as this:
Custom.SomeRandomMacro

How do I go about doing that? I can't seem to find it in the devnet screens, nor can I find it in these forums.

If someone could help that would be greatly appreciated.

Thanks,
Brian Kellogg

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 10/23/2012 6:58:00 AM
   
RE:Custom context macros
Hi Brian,

Unfortunately, this functionality isn't provided in the current version of Kentico CMS. I'm very sorry for this inconvenience but after discussin with our developer I can say, they are already preparing option to create custom "namespaces" with macros for Kentico v8.

Anyway, thank you for your suggestion!

Best regards,
Martin Danko

User avatar
Member
Member
Brian.Kellogg-VinSolutions - 10/23/2012 8:47:39 AM
   
RE:Custom context macros
Alright, if custom namespaces aren't available then:

http://devnet.kentico.com/docs/7_0/devguide/index.html?types_of_macros.htm

In the custom macro section shows that you can do Custom.MACRONAME when it states: Alternatively, you can also enter custom macros as data macros with the Custom. prefix: {%Custom.Expression%}... however, I cannot find additional information about that, and this is how I got my idea. How do I at least get the Custom.MACRONAME namespace to work?

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 10/23/2012 10:37:49 AM
   
RE:Custom context macros
Hi Brian,

sorry for that, there is probably wrong explanation in the DevGuide, I will discuss that with our technical writers.

However, I've found that in the Kentico v7 you can use:
{% Custom["custom_macro"] %}

Does it meet your expectations?

Best regards,
Martin Danko

User avatar
Member
Member
Brian.Kellogg-VinSolutions - 10/23/2012 2:23:41 PM
   
RE:Custom context macros
Yeah, that will certainly work for now, I just wanted to get a little fancier... =]

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 10/24/2012 1:57:32 AM
   
RE:Custom context macros
Hey Brian,

could you please tell me which version of Kentico are you actually running? Thanks.
I will check all possible options for macros syntax.

Best regards,
Martin Danko

User avatar
Member
Member
Brian.Kellogg-VinSolutions - 10/24/2012 8:43:59 AM
   
RE:Custom context macros
We're on version 7.

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 10/24/2012 9:25:19 AM
   
RE:Custom context macros
Hi,

in v7 it is also possible to use following format:
{%Custom.Expression%}

I think... this will exactly meet your idea :)

Best regards,
Martin Danko