Hi Charlie, sorry if I made you confuse my problem.
step 1: I create partial view macro and add parameter property.
step 2: I put that macro in tempate and set value to parameter.
step 3: I would like to get value of parameter in partial view macro. but I can use @Model.Macroname, @Model.MacroAlias but I can't use @Model.MacroParameters
Hi, are you using razor? and what data are you trying to pass in as a parameter? I am just wondering if there is a better way of getting this information :). Charlie
Yes, I'm using razor for implement. I create content picker as macro parameter for choosing a content node in the content section. so I have to get node Id (int) of the page.
when I had node Id, I can get some details of that Node
example: nodeName, create by, NiceUrl or some properties
Hi, sorry for the late reply. Why can you not just get the id out of @model or instance a new node and get the property in your .cshmtl View/PartialView?? May be i am missing something? Why do you need a macro parameter? Charlie :)
ex: richtext editor, template, patial view and partial view macro
2. I can choose any nodes, if I would like.
ex: I made the advertisment collections and have many advertisment item nodes under the collection hierachy, I can use macro for choose only root node of the collection after that I can display all of them.
3. In patial view, we can pass some parameter to another patial view by using macro parameter.
Umbraco 6.1 How to get macro parameter in partial view macro
I'm a newbie for implement partial view macro in Umbraco 6.1. I create a macro name: DisplayContent and havea pararmeter call PageId
I put this macro on template like this
@Umbraco.RenderMacro("DisplayContent", new {PageId="1234" })
and then in partial view macro,I try to use @Model.MacroParameters for show that parameter
but I can't use this method for get that parameter.
How should I do? please suggestion
PT
http://www.proworks.com/blog/2013/02/22/umbraco-6-views,-partial-views,-and-partial-view-macro-files/
Here we go about half way down :)
@Charles, Thank you for your suggestion. Normally, I did with XSLT like
or Can I get value from Xslt?
Any idea for get macro parameter in parital view?
Hi Patompol, if you are using razor you wont be able to use XSLT. What data are you trying to access in which location? Thanks. Charlie :)
Hi Charlie, sorry if I made you confuse my problem.
step 1: I create partial view macro and add parameter property.
step 2: I put that macro in tempate and set value to parameter.
step 3: I would like to get value of parameter in partial view macro. but I can use @Model.Macroname, @Model.MacroAlias but I can't use @Model.MacroParameters
Thanks for your reply.
Hi, are you using razor? and what data are you trying to pass in as a parameter? I am just wondering if there is a better way of getting this information :). Charlie
Yes, I'm using razor for implement. I create content picker as macro parameter for choosing a content node in the content section. so I have to get node Id (int) of the page.
when I had node Id, I can get some details of that Node
example: nodeName, create by, NiceUrl or some properties
Node node = new Node(node Id);
Hi ,
If you are using razor you could try this instead
Hope this helps
//fuji
@Fuji, Thanks for your help. but I think that is syntax of Umbraco 5. I can't use on partial view macro in Umbraco 6.1
Perhaps, I forgot define @using ..... at the head of the partial view. if I wrong, please explain more to me. :))
Hi Patompol,
I myself am not very used to Partial Views but if you are only using razor this should work and add
This morning, I can found the syntax for get value from Macro parameter
Thank you everyone,
PT
Hi, sorry for the late reply. Why can you not just get the id out of @model or instance a new node and get the property in your .cshmtl View/PartialView?? May be i am missing something? Why do you need a macro parameter? Charlie :)
Glad you got it fixed though
I would like macro because
1. I can insert macro at anywhere
ex: richtext editor, template, patial view and partial view macro
2. I can choose any nodes, if I would like.
ex: I made the advertisment collections and have many advertisment item nodes under the collection hierachy, I can use macro for choose only root node of the collection after that I can display all of them.
3. In patial view, we can pass some parameter to another patial view by using macro parameter.
PT
Ah ok that makes sense :). Thanks,
I'm trying to get parameters on Macro Partial Views too.
The only way to access is using Model.MacroParameters dictionary? It seems a little bit nasty.
Would be nice having some extension method helpers to retrieve parameters.
Whatever, thank you for code Patompol!
Isin't this the only way now:
@Model.MacroParameters["yourParameter"]
thank you for posting the solution!
I'm currently trying to pass parameters to my Razor view, but my Model.MacroParameters remains empty.
I've got this in my template (taken from this example):
So how come my Model.MacroParameters isn't showing any key/value pairs?
Problem solved.
It was because I hadn't set up the macro parameter on the parameters tab in the macro section.
is working on a reply...