How to add a macro to an umbraco page when using the markdown editor

EDIT:

What I really need is an editor that'll allow me to write html directly and allow inserting macros.

I'm using WMD editor in umbraco 7 and need to add a partial view macro to the page.

The editor does not have an insert macro button and if I pasted the following code in the editor, it is not shown in the page. I think the markdown processor removes it from the page ; <umbraco:Macro Alias="YourMacroAlias" \>

How can I add the macro to the page ?

Answers


Out of the box, the WMD editor does not support embedding Macros in the same way as the Richtext Editor does. You could raise a feature request at http://issues.umbraco.org and see if they'll add it, or you could take the source of the WMD from the Umbraco source at https://github.com/umbraco/Umbraco-CMS and create your own version of the markdown editor based on it.

The way the Richtext editor does it is that it stores the macro details as a specially formatted bit of markup, and there's some code in the front end that looks for that markup and replaces it with the output of the Macro.


Go to the developer section. Open the Macros. In your macro there is a checkbox "Use in rich text editor and the grid" and "Render in rich text editor and the grid" check this.

For Using in Rich Text the option must be checked in the Data Type. In the Developer section there is below Data Types, the Richtext editor data type check umbmacro.

In the Rich Text editor there is a "Insert Macro" Button, the 2 gears icon.

But for a markdown datatype there is no button, no support, An option is invent a tag a replace you tag in the template with somethings else. To come a bit near a macro functionality.


Instead of using Markdown editor for less options, you can disable excess commands for the tinyMce too. Extra tags added by tinyMce can also be disabled, see at end

Firstly there is file in config folder named tinyMceConfig.config. It handles the options in all datatypes using tinyMce. Below is entry for macro

<command>
    <umbracoAlias>umbracomacro</umbracoAlias>
    <icon>images/editor/insMacro.gif</icon>
    <tinyMceCommand value="" userInterface="true" frontendCommand="umbmacro">umbracomacro</tinyMceCommand>
    <priority>62</priority>
</command>

Go to

Developer -> DataTypes -> Rich Text Editor

There will be toolbar checkbox list. Select umbmacro from the list and save the data type. You will see the macro on the WYSIWYG editor. Uncheck all unwanted options. Also you can create new datatype say "RTE Lite" using property editor "Rich Text Editor" and use this "RTE Lite" where less options are needed.

Edit: Okay, if you do not like extra p tag added by tinyMce, go to "tiny_mce_src.js" file from your umbraco solution, search for forced_root_block : 'p' and change it to forced_root_block : ''


Need Your Help