0

I use the version 4 of Umbraco, and wondering if there is a way to render a module from an other module.

say

Root
=> Folder1
=>=> Page1
=>=>=> PageLayout
=>=>=>=> MainContentZone

=>=>=>=>=> MyMainModule

=>=>=>=>=>=> MyChildModule1
=>=>=>=>=>=> MyChildModule2
=>=>=>=>=>=> ...
=>=>=>=>=>=> MyChildModuleX

I would like to iterate over child modules from MyMainModule and display them all. Something like this

@{
    var myLayoutHelper = new LayoutHelper(this);
    var modules = myLayoutHelper.CurrentModules;
}

@foreach (var mod in modules)
{
    <div>
        @myLayoutHelper.RenderModule(mod)
    </div>
}

Is it possible?

serhio
  • 28,010
  • 62
  • 221
  • 374

1 Answers1

0

Yes, you can call an other macroScript from a macroScript

@foreach(var mod in modules) 
{
    @RenderPage("~/MacroScripts/Mod-Detail.cshtml", mod.Id);
}

and then in the Mod-Detail page you can pick up the id like this:

int myId = PageData[0];

Update:

For those using Umbraco v6 in MVC modus try

@Html.Partial("PartialName")
@Html.CachedPartial("PartialViewName", model:myModel, cachedSeconds:60, cacheByPage:true, cacheByMember:false,   viewData:AViewDataDictionary)
@Umbraco.RenderMacro("MacroAlias")   // to render a macro
dampee
  • 3,392
  • 1
  • 21
  • 37