Hello,
I have made an Itemtype consisting of the following field types: product, dropdownlist and file. But I can't get it working in my razor template. The code i'm using is:
@using Dynamicweb.Content.Items; @using System.Web; @{ var request = HttpContext.Current.Request; var response = HttpContext.Current.Response; var items = GetLoop("ItemPublisher:Items.List"); var pageTitle = @Pageview.Page.get_Value("PageMenuText"); } <h2>On page "@pageTitle" I see @items.Count items</h2> @foreach (LoopItem item in items) { <table> @foreach (LoopItem field in item.GetLoop("ItemPublisher:Item.Fields")) { <tr> @field.TemplateTags() </tr> } </table> }
The error occurs when I insert the line "@field.TemplateTags()", so this makes debugging for me very difficult because of the failing TemplateTags.
The error I'm getting is:
Exception in template (Designs\Pentair\eCom/Product/Product.cshtml): System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at Dynamicweb.eCommerce.Frontend.Renderer.FixPathAndQuery(String PathAndQuery, String GroupID)
at Dynamicweb.eCommerce.Frontend.Renderer.RenderProduct(Product Product, Boolean ExtendedProperties, Template Template, Int32 loopCounter, Boolean renderRelated, String productURL, Int32 quantity, Int32 wishListID, Boolean renderPublicList, Int32 orderLineOfProductCount)
at Dynamicweb.Content.Items.Editors.ProductEditor.RenderProducts(EditorRenderingContext context)
at Dynamicweb.Content.Items.Editors.ProductEditor.RenderValue(EditorRenderingContext context)
at Dynamicweb.Content.Items.Rendering.Renderer.RenderValueInternal(Object value, Type valueType, Template template, String tagName, ItemField meta, Boolean tryRenderLinkedItem, ItemEntry itemEntry)
at Dynamicweb.Content.Items.Rendering.Renderer.RenderItemField(ItemField field, Object value, Dictionary`2 validationErrors, Boolean allowEditing, Template template, String tagPrefix, ItemEntry itemEntry)
at Dynamicweb.Content.Items.Rendering.Renderer.RenderItem(ItemEntry item, ItemSettings settings)
at Dynamicweb.Content.Items.Rendering.Renderer.RenderItems(IEnumerable`1 items, ItemListSettings settings)
at Dynamicweb.Modules.ItemPublisher.Frontend.List()
at Dynamicweb.Modules.ItemPublisher.Frontend.GetContent()
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Dynamicweb.Extensibility.AddInManager.InvokeFunction(Object instance, String FunctionName, Object[] Params)
at Dynamicweb.Rendering.RazorTemplateBase`1.RenderItemList(Object settings)
at CompiledRazorTemplates.Dynamic.eccbbbee.Execute()
at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context)
at RazorEngine.Razor.Parse[T](String razorTemplate, T model, String cacheName)
at Dynamicweb.Rendering.Template.Output()
What I want is to list / loop throug the item fields and working templatetags would be very welcome. Can somebody help me out?
Greetings Harald