1

I have pushed a package variable of type "ComponentPresentationList" with name "MainSectionComponents". I have written razor template code to render the componentpresentation list.

   @foreach (var cp in Package.MainSectionComponents) {
     @cp.RenderComponentPresentation()
    }

When I try to run it in template builder I get following exception.

DynamicItemFields: Key 'rendercomponentpresentation' Not Found In ItemFields Cannot perform runtime binding on a null reference at CallSite.Target(Closure , CallSite , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0) at CallSite.Target(Closure , CallSite , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0) at Tridion.Extensions.Mediators.Razor.Templating.Rzr881cef20770a4632b97928a77eaf9c6dTemplate.Execute() at Tridion.Extensions.Mediators.Razor.RazorHandler.CompileAndExecute(DateTime revisionDate, Engine engine, Package package) at Tridion.Extensions.Mediators.Razor.RazorMediator.Transform(Engine engine, Template template, Package package) at Tridion.ContentManager.Templating.Engine.ExecuteTemplate(Template template, Package package) at Tridion.ContentManager.Templating.Engine.InvokeTemplate(Package package, TemplateInvocation templateInvocation, Template template) at Tridion.ContentManager.Templating.Compound.CompoundTemplateMediator.Transform(Engine engine, Template templateToTransform, Package package) at Tridion.ContentManager.Templating.Engine.ExecuteTemplate(Template template, Package package) at Tridion.ContentManager.Templating.Engine.InvokeTemplate(Package package, TemplateInvocation templateInvocation, Template template) at Tridion.ContentManager.Templating.Engine.TransformPackage(Template template, Package package) at Tridion.ContentManager.Templating.Debugging.DebuggingEngine.Run() at Tridion.ContentManager.Templating.Debugging.DebugSession.Run()

Can somebody please guide me in the right direction ?

2 Answers 2

2

Problem was that the package variable "MainSectionComponents" was pushed in as "ContentType.ComponentArray" instead of "ContentType.ComponentPresentationArray".This was giving following "DynamicItemFields: Key 'rendercomponentpresentation' Not Found In ItemFields" exception.

1
  • In your question you mentioned package variable of type "ComponentPresentationList", which is a separate type other than "ComponentArray" and "ComponentPresentationArray" as you mentioned in your answer. Please try to ask clear questions, it will help you getting good answers. Thanks Commented Mar 10, 2015 at 11:34
0

I think you should first check if item "MainSectionComponents" exists in the package and is not null.

Also, I am not sure, ComponentPresentation class supports method RenderComponentPresentation(). So if @cp.RenderComponentPresentation() dosn't work, you can try using TridionHelper.Engine.RenderComponentPresentation(cp.Component, cp.ComponentTemplate); inside the foreach loop.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.