One issue that comes up from time to time is the need to add a MNTP-like data type as a macro parameter. Somewhat surprisingly to me, there isn't yet a solution for this out there (or I couldn't find one) - I would have thought that this would be a fairly common problem for people. I have frequently worked around this by using multiple content pickers instead (which is limited and very inelegant) - I was wondering however if there was a better solution for this and/or if there was a Umbraco HQ endorsed solution for this problem?
If you're using Umbraco 7 then you should be able to turn any property editor into a macro parameter. It's described how to do it in the angular workbook for Umbraco here https://github.com/umbraco/AngularWorkbook/blob/master/Exercises/Exercise10.md - If you have not gotten any experience with AngularJs yet then I suggest you work through the entire book.
This isn't necessarily true. Half the time you will experience errors such as $scope.model.config is null because the documentation states all you need to do is add a single line when most of the time that is not the case. Like now, I'm trying to create a multiple content picker from scratch that can be used as a macro parameter, because this functionality does not (and should) exist in the core, and all i'm getting is this annoying stupid error all the time that the angular workbook doesn't even mention!
I can imagine that the methods etc. displayed in there are deprecated / obsolete - But perhaps there a newer methods etc. available, which can make you achieve the same.
where contentpicker.html and contentpicker.controller.js are extracted from (1) and (2).
The good news is that this doesn't seem to have broken anything and indeed, it appears correctly now as a macro parameter when added to my macros. It doesn't actually work however - I get a whole bunch of JS errors in the console so something's not set up correctly or potentially something is missing.
Have you set the "Debug" attribute in your web.config file to true? If not do that and the make sure to clear your browser cache and then recycle the app pool and then you should be good to go. If not then please post the errors from the browser console log.
Hi Thomas. I get the picker to work 75%. I can pick items and retrieve them from code. But when I edit the macro it doesn't seem to render the picks, and it gives a blank list every time. Do you get the same?
Can't get it to work here. Instead I continued down Josephs track by extracting code from \umbraco\views\propertyeditors\contentpicker\contentpicker.html and \umbraco\Js\umbraco.controllers.js.
I moved more of the properties into the defaultConfig property, when I got the same error as Joseph mentioned. I also removed all validation regarding minNumber and maxNumber because it caused some errors and I do not need it.
Heroes don't always wear capes. In this case Tommy Enger for a solution that uses Umbraco 7.2.4, this code has saved my bacon. I thankyou sir. Hopefully now someone will sort out this frankly embarassing mess and finally add this to the core!
Its working now but i didn't change any code. Just unchecked the mandatory option. saved. tested and its ok. marked again as mandatory and works. can't reproduce the bug. :(
Using a multi-content picker as a macro parameter
Hello
One issue that comes up from time to time is the need to add a MNTP-like data type as a macro parameter. Somewhat surprisingly to me, there isn't yet a solution for this out there (or I couldn't find one) - I would have thought that this would be a fairly common problem for people. I have frequently worked around this by using multiple content pickers instead (which is limited and very inelegant) - I was wondering however if there was a better solution for this and/or if there was a Umbraco HQ endorsed solution for this problem?
cheers Joseph
Hi Joseph
If you're using Umbraco 7 then you should be able to turn any property editor into a macro parameter. It's described how to do it in the angular workbook for Umbraco here https://github.com/umbraco/AngularWorkbook/blob/master/Exercises/Exercise10.md - If you have not gotten any experience with AngularJs yet then I suggest you work through the entire book.
Hope this helps.
/Jan
This isn't necessarily true. Half the time you will experience errors such as $scope.model.config is null because the documentation states all you need to do is add a single line when most of the time that is not the case. Like now, I'm trying to create a multiple content picker from scratch that can be used as a macro parameter, because this functionality does not (and should) exist in the core, and all i'm getting is this annoying stupid error all the time that the angular workbook doesn't even mention!
Thanks for that angular workbook! I have been looking for something similar to get me going on Umbraco 7!
For Umbraco 6 (and below) solutions however - do you have any recommendations around a multi-content picker macro parameter?
Hi Joseph
You're very welcome :)
Hmm, I don't know other information about how to do it in older versions than what Richard writes about here http://www.richardsoeteman.net/2010/01/04/CreateACustomMacroParameterType.aspx - But be aware that this is very old information since the post is from 2010 and A LOT has happened since.
I can imagine that the methods etc. displayed in there are deprecated / obsolete - But perhaps there a newer methods etc. available, which can make you achieve the same.
Hope this helps.
/Jan
Hi Joseph,
For Umbraco 6, you could try to see the documentation, http://our.umbraco.org/Documentation/Extending-Umbraco/Macro-Parameter-Editors/ and this old post from Richard Soeteman http://www.richardsoeteman.net/2010/01/04/CreateACustomMacroParameterType.aspx
Hope this helps,
/Dennis
Thanks all!
Hello
I've made a start on trying to get this to work on Umbraco 7. Here's what I've done so far:
Added these to my manifest in App_Plugins as follows:
}
and
where contentpicker.html and contentpicker.controller.js are extracted from (1) and (2).
The good news is that this doesn't seem to have broken anything and indeed, it appears correctly now as a macro parameter when added to my macros. It doesn't actually work however - I get a whole bunch of JS errors in the console so something's not set up correctly or potentially something is missing.
Am I on the right track here?
Hi Joseph
Have you set the "Debug" attribute in your web.config file to true? If not do that and the make sure to clear your browser cache and then recycle the app pool and then you should be good to go. If not then please post the errors from the browser console log.
Cheers, Jan
Debug attribute, etc are all set. Here's the error:
It looks like something's not initialised properly?
Hi Joseph
What does the content of your view look like?
/Jan
Exactly the same as shipped with Umbraco:
Hi,
I'm just looking for the solution to pick up several ContentNodes as Macro Parameter and found these posts here.
Is there any progress? I don't understand why this basic functionality isn't implemented in the core. As far as I know, it was possible in V6.
Anyway, if anyone has a solution for this, could she / he provide a package?
Is there anything I can do to support this issue?
Best regards -
Tom
Hi there, found a solution.
This code here works:
https://gist.github.com/westfall/22dc3fe56a27f816ba0b/download#
In my partial view, I call:
And I get sort of this:
If a package is needed, let me know.
Great find Thomas!
Hi Thomas. I get the picker to work 75%. I can pick items and retrieve them from code. But when I edit the macro it doesn't seem to render the picks, and it gives a blank list every time. Do you get the same?
With me it works. But I know that the umbraco backend has a very hard caching. Tried it in another browser?
Can't get it to work here. Instead I continued down Josephs track by extracting code from
\umbraco\views\propertyeditors\contentpicker\contentpicker.html
and\umbraco\Js\umbraco.controllers.js
.I moved more of the properties into the defaultConfig property, when I got the same error as Joseph mentioned. I also removed all validation regarding minNumber and maxNumber because it caused some errors and I do not need it.
My source code can be found here https://db.tt/v5bbQXsF (Still needs more testing)
Can be used from the view like this (would not do it like this, but you get the idea)
Heroes don't always wear capes. In this case Tommy Enger for a solution that uses Umbraco 7.2.4, this code has saved my bacon. I thankyou sir. Hopefully now someone will sort out this frankly embarassing mess and finally add this to the core!
Glad to help out. I have just added this and 2 more macro parameters to github: https://github.com/engern/Umbraco-custom-macro-parameters
Howdy!
I've just run into this issue as well. Did anyone ever find a lasting solution? The above mentioned doesn't seem to work for me on v7.4.1.
Also - any clue as to why this isn't included in the core? Seems like a pretty common usecase.
Hi all,
I'm having exactly the same problem. I cannot reiterate how much this SHOULD BE IN THE CORE!
For me, the solution Thomas provides above doesn't seem to reload the values either when I edit.
Anyone made any progress at all with this?
Same problem in v 7.5.2 :(
I had the same problem in 7.5.2 if its MANDATORY.
:/
Did you try the answer I gave here: https://our.umbraco.org/forum/developers/extending-umbraco/60243-Using-a-multi-content-picker-as-a-macro-parameter#comment-212579 ?
Hi Tommy Enger,
Thanks for the reply.
Its working now but i didn't change any code. Just unchecked the mandatory option. saved. tested and its ok. marked again as mandatory and works. can't reproduce the bug. :(
CACHE?
is working on a reply...