@{
var ft = Umbraco.Content(CurrentPage.featuredTrack);
var m4A = Umbraco.Media(ft.GetPropertyValue("M4A")).Url;
var ogg = Umbraco.Media(ft.GetPropertyValue("OGG")).Url;
}
@Umbraco.RenderMacro("HomepageFeaturedTrack",
new {trackTitle=Umbraco.Content(CurrentPage.featuredTrack).GetPropertyValue("title"),
trackM4A=m4a,
trackOGG=ogg})
To read the value of the macro parameters you have passed.
So:
string trackTitle = Model.GetParameterValue
should work ?
as long as 'trackTitle' is an alias of a property setup on the Macro in the Umbraco back office
(I'd probably just past the featuredTrack Id into the macro, and do the work to retrieve the title, m4A and ogg Url values in there, rather than passing them ?)
Umbraco 7 render macro with page properties
Hi,
I would like to know how to render a macro with page properties as parameters.
For example, my page has 3 properties:
The macro renders PartialViewMacroFiles that launch a javascript:
So in my razor script I wrote this:
It's not working.
Could anyone have an idea how to make it work?
Thanks in advance.
In your PartialViewMacro you can use:
Model.GetParameterValue
To read the value of the macro parameters you have passed.
So:
string trackTitle = Model.GetParameterValue
should work ?
as long as 'trackTitle' is an alias of a property setup on the Macro in the Umbraco back office
(I'd probably just past the featuredTrack Id into the macro, and do the work to retrieve the title, m4A and ogg Url values in there, rather than passing them ?)
Yeah, indeed it works better with the trackID as parameter. But I kept the Model.MacroParameters, it works better. (in my case)
is working on a reply...