I just searched the web, for trying to help you further, and I found a relativly new blogpost from the22 Feb 14 about usingmacro-container in MVC. Maybe this can help you further.
Thanks again - I've already seen that post and I'm having a hard time believing that all this is necessary. Kind of defeats the point of the Macro Container...
Using the old umbraco.library which is still available. You can pass a macro text string and a pageid(mandatory) and it will render your macro container for you.
In my (6.1.6) application a Macro Container is used on a field in a DocumentType. The field is rendered in the MVC template with the following statement:
@Umbraco.Field("headerSection", recursive: true)
(In case you're wondering: the recursive part searches up the content tree until it finds a field with that alias)
I am currently working on a problem like this in Umbraco 7.1.4.
My site structure looks like this:
Danish company name (homepage doctype)- SubpagesLanguage version folder- English version (called EN, also homepage doctype)-- Subpages
The idea is that the webmaster manually inserts the menu on each new language he creates. With a macrocontainer, with the alias indsaetMenu, placed on the homepage doctype.
The menu renders on the frontpage, but when I navigate to a subpage the menu is gone. So my question is how do I rewrite it so it does not rely on currentpage? Or mabye it's just missing some recursive function?
Rendering Macros From Macro Container MVC
Hey
I'm trying to display a simple macro, which has been chosen in a macro container.
When using @Umbraco.Field("macroPicker") the output to the html is:
< ! --?UMBRACO_MACRO macroAlias="SearchForm" /-->
How do I render macros from the Macro Container?
Hi Tom
You could try something like this:
The documentation about this can you find here: http://our.umbraco.org/documentation/Reference/Mvc/partial-views
Hope this helps,
/Dennis
Hey Dennis - thanks for the reply.
I'm not just trying to render a macro. I'm trying to render a list of macros, which has been selected in a Macro Container property editor.
Hi Tom,
I just searched the web, for trying to help you further, and I found a relativly new blogpost from the22 Feb 14 about usingmacro-container in MVC. Maybe this can help you further.
http://sam-mullins.com/articles/how-i-hack-the-macro-container-into-working-with-mvc/
/Dennis
Thanks again - I've already seen that post and I'm having a hard time believing that all this is necessary. Kind of defeats the point of the Macro Container...
Hi Tom.
Maybe you have solved your problem by now, if not though, here's how I fixed it in Umbraco 7.
@Html.Raw(umbraco.library.RenderMacroContent(CurrentPage.textColumns, CurrentPage.Id))
Using the old umbraco.library which is still available. You can pass a macro text string and a pageid(mandatory) and it will render your macro container for you.
Hth
- Sune
Thanks alot, I'll try that.
Tom,
In my (6.1.6) application a Macro Container is used on a field in a DocumentType. The field is rendered in the MVC template with the following statement:
@Umbraco.Field("headerSection", recursive: true)
(In case you're wondering: the recursive part searches up the content tree until it finds a field with that alias)
Hi guys
I am currently working on a problem like this in Umbraco 7.1.4.
My site structure looks like this:
Danish company name (homepage doctype)- SubpagesLanguage version folder- English version (called EN, also homepage doctype)-- SubpagesThe idea is that the webmaster manually inserts the menu on each new language he creates. With a macrocontainer, with the alias indsaetMenu, placed on the homepage doctype.
Using the:
The menu renders on the frontpage, but when I navigate to a subpage the menu is gone. So my question is how do I rewrite it so it does not rely on currentpage? Or mabye it's just missing some recursive function?
Any ideas? :)
/Michael
This works for me:
@Umbraco.RenderMacro("NameofMacro", new { Parameter = CurrentPage.Property})
is working on a reply...