Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have an Umbraco 4.11 site with a Macro I have created. It has a parameter called ArticleId.
I am currently trying to pass it like this...
@Umbraco.RenderMacro("ForeignArticleWrapper", new { ArticleId = Umbraco.Field("featuredArticle").ToString() });
I have also tried...
@Umbraco.RenderMacro("ForeignArticleWrapper", new { ArticleId = 1090 });
I am trying to render the value in the macro using
@Parameter.ArticleId, but it returns nothing.
What am I doing wrong?
I have the same problem but I can't find a single clue.
It's like the @Umbraco.RenderMacro doesn't work! Even the syntax @Umbraco.RenderMacro("MacroName") doesn't work.
Do you have found something?
Thanks
I also have the same problem in Umbraco 6. Please help..
I ended up replacing all my Macros with Partial Views instead.
Try
Model.MacroParameters["ArticleId"]
instead of
@Parameter.ArticleId ..
This is tested for version 6, I don't know if it still works for v4.
This might also help: http://umbraco.com/follow-us/blog-archive/2012/10/30/getting-started-with-mvc-in-umbraco-410.aspx
Jeroen
Here are the first few lines of a macro I have that has a parameter being passed in. If you don't already have these inherits or usings, try adding them and see if you have any luck.
@inherits umbraco.MacroEngines.DynamicNodeContext
@using umbraco.MacroEngines;
@using umbraco;
@{
var numItems = int.Parse(Parameter.numItems);
}
You almost there. One major thing you missed was to add ArticleId in the list of parameters for the macro in the developer section
In the template
@Umbraco.RenderMacro("YourMacro" ,new {ArticleId = @Umbraco.Field("yourField")})
In the XSLT
<xsl:param name="ArticleId" select="/macro/ArticleId"/>
Then you can do what you want with it
<xsl:value-of select="$ArticleId" />
Again don't forget to add ArticleId as a parameter to your macro from the developer section in umbraco
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How do I pass parameters to and read from them in a Razor macro?
I have an Umbraco 4.11 site with a Macro I have created. It has a parameter called ArticleId.
I am currently trying to pass it like this...
@Umbraco.RenderMacro("ForeignArticleWrapper", new { ArticleId = Umbraco.Field("featuredArticle").ToString() });
I have also tried...
@Umbraco.RenderMacro("ForeignArticleWrapper", new { ArticleId = 1090 });
I am trying to render the value in the macro using
@Parameter.ArticleId, but it returns nothing.
What am I doing wrong?
I have the same problem but I can't find a single clue.
It's like the @Umbraco.RenderMacro doesn't work! Even the syntax @Umbraco.RenderMacro("MacroName") doesn't work.
Do you have found something?
Thanks
I also have the same problem in Umbraco 6. Please help..
I ended up replacing all my Macros with Partial Views instead.
Try
Model.MacroParameters["ArticleId"]
instead of
@Parameter.ArticleId ..
This is tested for version 6, I don't know if it still works for v4.
This might also help: http://umbraco.com/follow-us/blog-archive/2012/10/30/getting-started-with-mvc-in-umbraco-410.aspx
Jeroen
Here are the first few lines of a macro I have that has a parameter being passed in. If you don't already have these inherits or usings, try adding them and see if you have any luck.
@inherits umbraco.MacroEngines.DynamicNodeContext
@using umbraco.MacroEngines;
@using umbraco;
@{
var numItems = int.Parse(Parameter.numItems);
}
You almost there. One major thing you missed was to add ArticleId in the list of parameters for the macro in the developer section
In the template
In the XSLT
Then you can do what you want with it
Again don't forget to add ArticleId as a parameter to your macro from the developer section in umbraco
is working on a reply...