Developer forum

Forum » Templates » Paragraphs container (items loop)

Paragraphs container (items loop)

Jens Mouritzen
Jens Mouritzen
Reply

I'm trying to loop items with a file include. Basicly i'm trying to make a simple paragraph container like the one in Rapido

I got the following error

Exception in template (Designs/Simple/Paragraph/ParagraphContainer.cshtml): System.ArgumentException: No template could be resolved with name 'Paragraphs.cshtml'
   at RazorEngine.Templating.TemplateBase.Include(String cacheName, Object model)
   at RazorEngine.Templating.TemplateBase`1.Include(String cacheName, Object model)
   at CompiledRazorTemplates.Dynamic.dafafcfbbdfe.Execute()
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context)
   at RazorEngine.Templating.TemplateService.Run(ITemplate template, DynamicViewBag viewBag)
   at RazorEngine.Templating.TemplateService.Parse(String razorTemplate, Object model, DynamicViewBag viewBag, String cacheName)
   at RazorEngine.Razor.Parse[T](String razorTemplate, T model, String cacheName)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @foreach(var i in(GetLoop("Item.Paragraphs"))){ Include("Paragraphs.cshtml"); }

I have attached the template files used

 


Replies

 
Nicolai Pedersen
Reply

It is called @Include for dynamicweb template to understand it.

You have made the include inside the loop. That is probably not the best idea - instead create a helper in the included file, and call that inside your loop.

BR Nicolai

 
Jens Mouritzen
Jens Mouritzen
Reply

The included file contains a lot of helpers, and i can't nest them. Any other suggestions ?

 
Nicolai Pedersen
Reply

Re-invent Razor?

Or re-structure the helpers in the include.

 
Kim Pilgaard
Reply

@Jens Without seeing your code (can't view it) it sounds like a use case for a razor helper function? Depending on your Dynamicweb version you may be able to use this https://doc.dynamicweb.com/forum/templates/razor-partial-views-and-helper-functions?PID=1605 .

 

You must be logged in to post in the forum