is there a way to restrict specific macros per grid? In my specific example I have tree grid property editors and 5 macros. I will set which macros are available in the indivual grid:
grid1:
macro1
macro 2
macro 3
macro 4
grid2:
macro2
macro5
grid3:
macro1
macro2
macro5
Is this possible? I can only allow the macro for all grids or not, but I can'f found a settings to select individuals macros in the grid property editor.
You can limit which property editors that´s allowed in the row configuration, so for a specific row configuration only have the property editors that you allow, and not all. try to see this documentation in the row configuration section.
thank you. You're right, but there is the requirement to use the default macro property editor from grid. But with this I see ALL macros that are allowed for a grid. And I can't select individual grids.
If this is not supported, you have now given me another idea :-)
I make a copy of the default macro grid property editor and his angularJS controller and edit this for my requirements. Really, after this it's not the default macro property editor, but it seems like this. I have to still think how I do the configuration, so as I select which macro to be available in which grid. Maybe I solve this via a custom dashboard or a custom section.
I have the same situation, although I don't have solution yet. Is it possible to limit what maros are availble via the grid config somehow?
{
"name": "Macro",
"alias": "macro",
"view": "macro",
"icon": "icon-settings-alt"
},
Maybe passing a prevalue list of some kind? I can't see how the Macro property editor works, i'm guessing it's complied rather than just plain html+js so I may have to try dig through the source, but if anyone else has an idea, i'd love to hear it!
Following up on this as it does not seem like a real answer has been provided. I am finding in the umbraco.controllers.js file a section related to limiting the allowed templates:
if (angular.isArray($scope.dialogData.allowedMacros) && $scope.dialogData.allowedMacros.length > 0) {
I would like to restrict the macros by the row type. For example, if the row type were a Header; I would like only section header, section footer, section sub header and section subfooter for that type of row.
I think it would be easy to do if I could identify the currently edited row (possibly area for future purposes) at the point of checking the allowedMacros or at the point of setting the config. Any idea how I can identify the currently edited row and area from this location of the javascript?
2. Into the /App_Plugins/MyGrid/Views/macroCustom.htm I have copied the standard Umbraco macro property editor from \Umbraco\Views\propertyeditors\grid\editors\macro.html - but I have changed the controller to point to my own custom controller as below:
3. This allows us to change the SetMacro() method take account of the allowedMacros config setting. Again I copied the standard Umbraco macro controller from \Umbraco\Js\umbraco.controllers.js into my own control js file (so update your package.manifest etc etc). Modified controller looks like this:
Only difference from the Umbraco version is that the dialogData.allowedMacros is being set to our array. If you look at the code in the InsertMacroController in \Umbraco\Js\umbraco.controllers.js you will see that the macros in the dropdown are filtered by this.
The above solves a general problem I had, where I wanted to add more advanced components into the Grid - but was struggling to make custom grid editors handle advanced admin/edtior UI components.
Using the approach described here: http://24days.in/umbraco/2014/grid-macros/ you can use the details above to create what looks like custom grid editors (but is in fact a macro insert) - and utilise the Macro edting pane for the advanced UI components - and then finally use the preview method described in the mentioned post to make the macro look nice in the Umbraco backend grid layout.
Another way (as of 7.5.3 at least) is to to create entries in grid.editors.config.js for each macro you want to use in grid passing the macro alias in the config and then configure your grid layouts as usual.
Example using the App_Plugins approach with a package.manifest:
This does mean you may have quite a few grid editors to choose from when configuring your grid layouts, but does not require customisation of back office code and should work with Courier / UaaS as your not using a custom view. Then either use CSS for styling in back office or static content for complex things like Twitter as per the 24 days article.
I was able to use Gavin's method successfully. Just want to add that if you take this route, you'll still need to check the box in the macro for use in the Grid Editor.
Restrict macros per grid
Hello,
is there a way to restrict specific macros per grid? In my specific example I have tree grid property editors and 5 macros. I will set which macros are available in the indivual grid:
grid1:
Hi Sören,
You can limit which property editors that´s allowed in the row configuration, so for a specific row configuration only have the property editors that you allow, and not all. try to see this documentation in the row configuration section.
https://our.umbraco.org/documentation/using-umbraco/backoffice-overview/property-editors/built-in-property-editors-v7/grid-layout#Rowconfigurations
Hope this helps,
/Dennis
Hi Denniy,
thank you. You're right, but there is the requirement to use the default macro property editor from grid. But with this I see ALL macros that are allowed for a grid. And I can't select individual grids.
If this is not supported, you have now given me another idea :-)
I make a copy of the default macro grid property editor and his angularJS controller and edit this for my requirements. Really, after this it's not the default macro property editor, but it seems like this. I have to still think how I do the configuration, so as I select which macro to be available in which grid. Maybe I solve this via a custom dashboard or a custom section.
Thanks!
Sören
Hi,
I have the same situation, although I don't have solution yet. Is it possible to limit what maros are availble via the grid config somehow?
{
"name": "Macro",
"alias": "macro",
"view": "macro",
"icon": "icon-settings-alt"
},
Following up on this as it does not seem like a real answer has been provided. I am finding in the umbraco.controllers.js file a section related to limiting the allowed templates:
I would like to restrict the macros by the row type. For example, if the row type were a Header; I would like only section header, section footer, section sub header and section subfooter for that type of row.
I think it would be easy to do if I could identify the currently edited row (possibly area for future purposes) at the point of checking the allowedMacros or at the point of setting the config. Any idea how I can identify the currently edited row and area from this location of the javascript?
Hi - I managed to solve this in version 7.2.4 as below. As an example I am using a TextWithPicsMacro macro.
1. Add a new custom grid editor into the grid.editors.config.js file:
Note that his has a allowedMacros config setting.
2. Into the /App_Plugins/MyGrid/Views/macroCustom.htm I have copied the standard Umbraco macro property editor from \Umbraco\Views\propertyeditors\grid\editors\macro.html - but I have changed the controller to point to my own custom controller as below:
3. This allows us to change the SetMacro() method take account of the allowedMacros config setting.
Again I copied the standard Umbraco macro controller from \Umbraco\Js\umbraco.controllers.js into my own control js file (so update your package.manifest etc etc). Modified controller looks like this:
Only difference from the Umbraco version is that the dialogData.allowedMacros is being set to our array.
If you look at the code in the InsertMacroController in \Umbraco\Js\umbraco.controllers.js you will see that the macros in the dropdown are filtered by this.
The above solves a general problem I had, where I wanted to add more advanced components into the Grid - but was struggling to make custom grid editors handle advanced admin/edtior UI components.
Using the approach described here: http://24days.in/umbraco/2014/grid-macros/ you can use the details above to create what looks like custom grid editors (but is in fact a macro insert) - and utilise the Macro edting pane for the advanced UI components - and then finally use the preview method described in the mentioned post to make the macro look nice in the Umbraco backend grid layout.
Another way (as of 7.5.3 at least) is to to create entries in grid.editors.config.js for each macro you want to use in grid passing the macro alias in the config and then configure your grid layouts as usual.
Example using the App_Plugins approach with a package.manifest:
This does mean you may have quite a few grid editors to choose from when configuring your grid layouts, but does not require customisation of back office code and should work with Courier / UaaS as your not using a custom view. Then either use CSS for styling in back office or static content for complex things like Twitter as per the 24 days article.
I was able to use Gavin's method successfully. Just want to add that if you take this route, you'll still need to check the box in the macro for use in the Grid Editor.
is working on a reply...