Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jeremy Schlosser 15 posts 146 karma points
    Apr 10, 2024 @ 23:00
    Jeremy Schlosser
    0

    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?

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Apr 11, 2024 @ 08:17
    Huw Reddick
    0

    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

  • Jeremy Schlosser 15 posts 146 karma points
    Apr 11, 2024 @ 18:42
    Jeremy Schlosser
    0

    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.

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Apr 11, 2024 @ 18:48
    Huw Reddick
    1

    Blocks can have a settings element which should work for that I believe

  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    Apr 11, 2024 @ 20:33
    Marc Goodson
    101

    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

  • Farhan Ali 5 posts 75 karma points
    Jul 23, 2024 @ 14:30
    Farhan Ali
    0

    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?

Please Sign in or register to post replies

Write your reply to:

Draft