I am using Partial View Macros and parameters extensively throughout my Umbraco v13.2.2 site. Since Macros and Partial View Macros are now deprecated and will not be included in Version 14, could someone provide some basic instructions for how to best move these parameter-fed partial view macros to Partials or Blocks?
Thanks for the reply, Huw. I don't think view components will work in this case. Currently, my site's contributors insert a partial view macro in the RTE, and add required parameters. The Contributors do not have access to razor views and sometimes don't know HTML. I suppose blocks would work, but it's not clear how or if the blocks can handle parameters.
For instance, we have one macro that displays a fluid meter (https://dec.alaska.gov/water/operator-certification/water-system-operator-reimbursement-program/). It takes a number as a parameter, entered by the contributor, and adjusts the meter based on that number. I'm struggling to figure out an alternative.
So you would create an Element Type reflecting the parameters of your Macro
Allow that Element Type to create a block that can be inserted into the RTE
And then each type of block would have a corresponding partial view which would replace your macro partial view, where you can access the parameters the editor has entered, and do the same logic as before.
In terms of migrating macros to the blocks
uSync Migrations allow you to convert old properties into new formats (even when not changing version)
I've migrated Macros in the Old Grid to Blocks in the New Grid, and can see how might be able to something similar with RTEs, will update if I get anything working (or if someone beats me to it!)
Upgrading to Umbraco 14: Migrating macros
I am using Partial View Macros and parameters extensively throughout my Umbraco v13.2.2 site. Since Macros and Partial View Macros are now deprecated and will not be included in Version 14, could someone provide some basic instructions for how to best move these parameter-fed partial view macros to Partials or Blocks?
Hi Jeremy,
I migrated all my macros to viewcomponents when I migrated to Umbraco 10.
Obviously it really depends what your macros are doing and where they are being used, but you may be able to use block grids and/or view components
Thanks for the reply, Huw. I don't think view components will work in this case. Currently, my site's contributors insert a partial view macro in the RTE, and add required parameters. The Contributors do not have access to razor views and sometimes don't know HTML. I suppose blocks would work, but it's not clear how or if the blocks can handle parameters.
For instance, we have one macro that displays a fluid meter (https://dec.alaska.gov/water/operator-certification/water-system-operator-reimbursement-program/). It takes a number as a parameter, entered by the contributor, and adjusts the meter based on that number. I'm struggling to figure out an alternative.
Blocks can have a settings element which should work for that I believe
Hi Jeremy
Rich Text Editors can now have blocks inside them for V13
https://docs.umbraco.com/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/rich-text-editor/rte-blocks
So you would create an Element Type reflecting the parameters of your Macro
Allow that Element Type to create a block that can be inserted into the RTE
And then each type of block would have a corresponding partial view which would replace your macro partial view, where you can access the parameters the editor has entered, and do the same logic as before.
In terms of migrating macros to the blocks
uSync Migrations allow you to convert old properties into new formats (even when not changing version)
https://github.com/Jumoo/uSyncMigrations
I've migrated Macros in the Old Grid to Blocks in the New Grid, and can see how might be able to something similar with RTEs, will update if I get anything working (or if someone beats me to it!)
regards
marc
Hi Marc,
Did you have any luck migrating RTE Macros to blocks?
I've never used uSyncMigrations before. Does it already have a migrator for it or we need to write custom migrator?
is working on a reply...