Add 'Macro Editor' to custom web part properties

Jason Herz asked on August 20, 2019 20:18

I have created several custom web parts with text fields and now that we're starting to load data into them, I've realized I need to add macros to certain fields, however, macros added just into the text box don't resolve. Looking through built-in web parts, I feel I need to add the 'Macro Editor' (little clickable triangle that opens the Macro dialog) to my fields to allow me to add the macros I require. I haven't been able to find any documentation on this, other than descriptions of what that 'macro editor' button is capable of. Does anyone have any suggestions as to how I can implement the 'Macro Editor' into a custom web part's text property? Thanks for your help in advance

Correct Answer

Brenden Kehren answered on August 20, 2019 20:50

When you say it doesn't work do you mean the output you get is the macro you entered in the field? If so, then you need to resolve that macro in your code behind. This can be done something like this:

var customPropertyValue = CMS.MacroEngine.MacroResolver.Resolve(CustomProperty);

So even though you won't get the macro UI to enter a macro, you can still enter macro syntax, it just needs to be handled after that.

2 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.