调用节点扩展字段方法问题

作者:动易软件 来源:本站原创 点击数: 发布时间:2023年08月07日

问题分析:模板有时候需要调用节点的扩展字段来显示,如下图

   

处理办法:

模板顶部先添加: @inject NodeExtendFieldService NodeExtendFieldService

然后对应的调用查询添加:

    if (node != null){
        var extendField = NodeExtendFieldService.GetAll();
        node.ExtendContentObject.InitExtendContent(extendField, node.ExtendContent);
    }


示例方法:

@{
                    var nodeService = NodeService;
                    var node = nodeService.GetNodeByIdentifier("jxyy");
                    var childNodes = nodeService.GetChildNodeList(node);
                    foreach (Node childNode in childNodes.Where(n => n.ShowOnParentNodeList))
                    {

                        if (childNode != null){
                            var extendField = NodeExtendFieldService.GetAll();
                            childNode.ExtendContentObject.InitExtendContent(extendField, childNode.ExtendContent);
                        }
                            <div class="swiper-slide swiper-no-swiping">
                                <div class="img">
                                        <img title="" alt="" src="  @StringExtensionsHelper.ToUrl(childNode.ExtendObject.jt)">
                                </div>
                                <div class="mask"
                                        style="background-image: url('@StringExtensionsHelper.ToUrl(childNode.ExtendObject.xt)'); ">
                                        
                                </div>
                                
                                <div class="ctrl">
                                </div>
                            </div>
                        }
  }