@{
var myCollection = CurrentPage.boxe.Split(',');
foreach (var item in myCollection)
{
@Html.Partial("myPartial", item)
}
}
Which throws the following error:
System.Web.Mvc.HtmlHelper<Umbraco.Web.Models.RenderModel>' has no applicable method named 'Partial' but appears to have an extension method by that name.
How do i then render the correct partial based on the doc types of the picked nodes?
Say, if: the "Herounit" doctype should render with the "myHeroUnit.cshtml" partial and the "Testemonial" doctype should render with the "myTestemonials.cshtml" partial?
The example below naturally just render both partials for each item picked with the picker...
@{
if (CurrentPage.HasValue("boxe"))
{
var bannerList = CurrentPage.boxe.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
var bannerCollection = Umbraco.Content(bannerList);
foreach (IPublishedContent item in bannerCollection)
{
@Html.Partial("myHeroUnit", item)
@Html.Partial("myTestemonial", item)
}
}
}
xslt "match template" & "include" in razor
As a big user of xslt macros and image crops, the new cropper has put me on the spot, as it is Razor only...
I'm looking to replicate a workflow i have in xslt, but i'm a bit clueles as how to do it in razor.
Im using the multinode treepicker to pick a series of document nodes of different doc type. I then list these nodes on the same page.
In xslt i have a base xslt file like this:
For each of the document types, i then have a xslt file which matches the doc type and serves as a template for the "Box":
How would one go about doing this in Razor?
Hi Claus,
Sounds like a perfect job for strongly type partial views where you can pass the IPublishedContent model.
Partial view "myPartial":
Then in your view:
Jeavon
Yeah, thats on the right track. Next step is to get nodes from the Multi node tree picker, and do the same.
I have:
Which lists the node names of the nodes chosen with the picker.
Now i need to render the partials of the chosen nodes instead... I'm lost again :)
I tried this
Which throws the following error:
System.Web.Mvc.HtmlHelper<Umbraco.Web.Models.RenderModel>' has no applicable method named 'Partial' but appears to have an extension method by that name.
You would need to get your picked nodes as IPublishedContent first, so it would be like this:
Cool, yeah that works. But the final thing.
How do i then render the correct partial based on the doc types of the picked nodes?
Say, if:
the "Herounit" doctype should render with the "myHeroUnit.cshtml" partial and
the "Testemonial" doctype should render with the "myTestemonials.cshtml" partial?
The example below naturally just render both partials for each item picked with the picker...
I guess I would do a switch like this:
EXACTLY! Awesome!
You're the @greystate of Razor. Thanks a lot!
But it sure does'nt have the readable beauty of the xslt.
Thanks! I am working on the v7 version of my converter package at the moment which will make this a lot smaller and nicer!
is working on a reply...