Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add doc for Inline Macro #4971

Merged
merged 7 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 43 additions & 4 deletions 11/umbraco-cms/reference/templating/macros/managing-macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ The second option is to create the macro through **Partial View Macro Files**.

The dialog provides the following options:

* New partial view macro: Will give you an empty macro with an associated empty partial view file
* New partial view macro (without macro): Will give you a partial view, without an associated macro
* New partial view macro from snippet...: Will give you the option to choose between a pre-defined set, including a macro and a partial view with a code snippet
* Folder...: Will give you the option to create a folder below "Partial View Macro Files"
- New partial view macro: Will give you an empty macro with an associated empty partial view file
- New partial view macro (without macro): Will give you a partial view, without an associated macro
- New partial view macro from snippet...: Will give you the option to choose between a pre-defined set, including a macro and a partial view with a code snippet
- Folder...: Will give you the option to create a folder below "Partial View Macro Files"

## Macro Editor

Expand Down Expand Up @@ -89,3 +89,42 @@ This list defines the different types of macro parameters:
- Content Picker (`Umbraco.ContentPicker`) - select a single content node from the Content tree
- Form Picker (`UmbracoForms.FormsPicker`) - choose from exising Umbraco Forms
- Forms Theme Picker (`UmbracoForms.ThemePicker`) - choose from existing Forms Themes

## Enable Inline Macro

In some case you want to have the macro in the middle of a sentence.

![Inline macros used multiple places inside a single Rich Text Editor](images/inline-macro-in-richtext.png)

To enable editors to add the macro inline, follow these steps:

1. Add a macro parameter called: **enableInlineMacro**.
2. Choose Checkbox (`Umbraco.TrueFalse`) as the type.

The next time you add the macro, enable the new parameter to add the macro inline.

### Enable Inline Macro by default on a macro

In some cases, you want to have a checkbox that is enabled by default. This would enable you to create your own type of macro parameter that has 1 as the default value. To achieve this, create a DataEditor class anywhere in your Umbraco Project with the following definition:

```csharp
[DataEditor(
alias: "enableInlineMacro",
type: EditorType.MacroParameter,
name: "Enable Inline Macro",
view: "boolean",
Group = "Macro Config",
Icon = "icon-list")]
public class EnableInlineMacro : DataEditor
{
public EnableInlineMacro(IDataValueEditorFactory dataValueEditorFactory)
: base(dataValueEditorFactory)
{
DefaultConfiguration.Add("default", "1");
}
}
```

{% hint style="info"%}
You can create a MacroParameter however you want, the importance is to have a parameter called enableInlineMacro with the value 1 to enable it.
{% endhint %}