The only reason why its a macro is because we had a rule that if we are going to pass values into a partial view then we will create macros instead, however, if its only possible to pass class types into a Partial views then I guess we will have to use them instead.
The macro was created to display content node properties so - IPusblishedContent.GetPropertyValue(""), so nothing that cant go into a partial view I guess.
I tried actually running the macro from the Rich Text Editor and selecting multiple nodes that way just to see if that worked but it just does the same thing.. since it's there as a type of macro parameter there surely must be a way to do it...
I'm struggling to find docs about how to deserialise the data from the Multi Content Picker parameter type.
@Valarie, thats a good point. I just put it as ContentPicker but I tried other types and they all seem to be passed in as a string.
I tried the multiple content type to see what it rendered in the umrbaco tools, and it does this - ["1117","1120"]- Which you probably already know.
Its then having to convert that into a collection of ints perhaps. So maybe we will have to write some logic to loop through each char of that string and pull out the numbers.
@Valerie - or like you mentioned before, you could use Partial views instead as you can pass in class types etc into them. But there could be a way via macros, I just dont know.
Can you pass IPublishedContent type into a Macro?
Hi guys,
I have been trying to pass in a IEnumerable
@Model.Content.Children returns IEnumerable
On my macro I try to do:-
But I get this error:-
Unable to cast object of type 'System.String' to type System.Linq.OrderedEnumerable`2[Umbraco.Core.Models.IPublishedContent,System.Int32]
So does that mean that you can only pass strings and ints into a macro or am I doing something wrong?
Cheers
Does this have to be a macro rather than a Html.Partial? What is it doing?
@Valerie
The only reason why its a macro is because we had a rule that if we are going to pass values into a partial view then we will create macros instead, however, if its only possible to pass class types into a Partial views then I guess we will have to use them instead.
The macro was created to display content node properties so - IPusblishedContent.GetPropertyValue(""), so nothing that cant go into a partial view I guess.
This is very strange, it's passing the type of the object as a string and I can't seem to be able to get to the actual object...
@Valerie - exactly. Thats the issue im having. I guess, we could just pass in the id of the content node and in the macro do:-
I was just wondering if it is possible to pass class types into the macro as it seems you can only pass ints and strings but I might be wrong.
I tried actually running the macro from the Rich Text Editor and selecting multiple nodes that way just to see if that worked but it just does the same thing.. since it's there as a type of macro parameter there surely must be a way to do it...
I'm struggling to find docs about how to deserialise the data from the Multi Content Picker parameter type.
Oh, turns out I just totally failed to read. It's multiple content types not content... but actually it has the same problem.
Actually, what "type" is your "Content" parameter in your macro? I can't see a Multiple IPublishedContent Picker.
@Valarie, thats a good point. I just put it as ContentPicker but I tried other types and they all seem to be passed in as a string.
I tried the multiple content type to see what it rendered in the umrbaco tools, and it does this - ["1117","1120"]- Which you probably already know.
Its then having to convert that into a collection of ints perhaps. So maybe we will have to write some logic to loop through each char of that string and pull out the numbers.
Yeah sounds like a plan :)
@Valerie - or like you mentioned before, you could use Partial views instead as you can pass in class types etc into them. But there could be a way via macros, I just dont know.
I'd just use a partial :) I normally only use macros these days if I am interacting with the Rich Text Editor but I'm not a huge macro user.
Is there any benefit to using a Macro instead when you have parameters?
@Valerie - We use them so that our front end developers can easily add a macro and pass values into them via the admin tools
Ah right! Colour me learned :)
is working on a reply...