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 9 posts 100 karma points
    22 days ago
    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 1746 posts 6110 karma points MVP c-trib
    21 days ago
    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 9 posts 100 karma points
    21 days ago
    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 1746 posts 6110 karma points MVP c-trib
    21 days ago
    Huw Reddick
    1

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

  • Marc Goodson 2141 posts 14344 karma points MVP 8x c-trib
    21 days ago
    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

Please Sign in or register to post replies

Write your reply to:

Draft