您的位置: 首页 >日志>动易系统>详细内容

动易系统

WF系统节点扩展字段的使用

来源:本站原创 发布时间:2022-12-30 14:35:16 浏览次数: 【字体:

分享WF系统节点扩展字段非本栏目页直接使用无效,研发提供的解决方法如下:

@{
    Node node = ViewBag.node;
    var topNode = NodeService.GetAncestorNode(node, 0);
    // 筛选这个节点的扩展字段数据。
    var extendField = NodeExtendFieldService.GetAll();
    topNode.ExtendContentObject.InitExtendContent(extendField, topNode.ExtendContent);
    if (!string.IsNullOrEmpty(topNode.ExtendObject.banner))
    {
        <div class="page-banner" style="background-image: url('@Power.ToUrl(topNode.ExtendObject.banner)');"></div>
    }
    else
    {
        <div class="page-banner"></div>
    }
}


第一:有此方法后,可以实现,顶部banner图片来源于本节点或者指定一级节点扩展字段的图片,代码如下:

@inject NodeService NodeService
@inject NodeExtendFieldService NodeExtendFieldService
@inject StringExtensionsHelper StringExtensionsHelper
@Power.VisualizationPartialView(new
{
    Description = "网站顶部"
})

@if (ViewBag.IsHome != true)
{
    Node node = ViewBag.node;
    if(ViewContext.RouteData.Values["area"].ToString().Contains("ContentManage")){
        if(Model is Node){
            node=Model;
        }
        else{
            node=Model.Node;
        }
    }
   
    if(node != null){
        if (!string.IsNullOrEmpty(node.ExtendObject.banner))
        {
            <div class="page-banner" style="background-image: url('@Power.ToUrl(node.ExtendObject.banner)');"></div>
        }
        else
        {
            var topNode = NodeService.GetAncestorNode(node, 0);
            // 筛选这个节点的扩展字段数据。
            var extendField = NodeExtendFieldService.GetAll();
            topNode.ExtendContentObject.InitExtendContent(extendField, topNode.ExtendContent);
            if (!string.IsNullOrEmpty(topNode.ExtendObject.banner))
            {
                <div class="page-banner" style="background-image: url('@Power.ToUrl(topNode.ExtendObject.banner)');"></div>
            }
            else
            {
                <div class="page-banner"></div>
            }
        }
    }
    else{
        <div class="page-banner"></div>
    }
}

第二:利用节点扩展字段时间比较通用的专题-首页模板,代码如下:

@inject NodeInterfaceExtend NodeInterfaceExtend
@inject NodeExtendFieldService NodeExtendFieldService
@inject NodeService NodeService
@{
    var childNodes = NodeService.GetChildNodeList(Model).Take(999);
    var lastOddClass = "";
    foreach (Node childNode in childNodes.Where(n => n.ShowOnParentNodeList))
    {
        // 筛选这个节点的扩展字段数据。
        var extendField = NodeExtendFieldService.GetAll();
        childNode.ExtendContentObject.InitExtendContent(extendField, childNode.ExtendContent);
       
        if (childNodes.Last().Equals(childNode))
        {
            lastOddClass = "lastOdd";
        }
        <dl class="box @lastOddClass">
            <dt class="mHd">
                <h3>@Power.Url.NodeLink(childNode.Identifier)</h3>
            </dt>
            <dd class="mBd">
                @if (childNode.MoldId == 1){
                    if(childNode.ExtendObject.zslx=="焦点图")
                    {
                        <div class="focusNewsBox">
                            <!-- 焦点图 S -->
                            <div id="box-@(childNode.Identifier)" class="focusBox">
                                    <ul class="bd swiper-wrapper">
                                    @Power.ArticleList("文章图片列表", new {Count=5, Node=childNode.Identifier, Illustrated=true, TitleLength=60, ImageWidth=600, ImageHeight=400,refnode = true })
                                    </ul>
                                    <!-- 分页 -->
                                    <div class="hd swiper-pagination">
                                    </div>
                            </div>

                            <script>
                                //焦点图轮播
                                $("#box-@(childNode.Identifier) .swiper-wrapper li").addClass("swiper-slide");
                                //焦点图轮播
                                var indFocus = new Swiper("#box-@(childNode.Identifier)", {
                                    autoplay: true,//自动播放
                                    loop: true, // 循环模式选项
                                    pagination: {
                                        el: ".swiper-pagination",
                                        clickable: true,
                                    },
                                });
                            </script>

                            <ul class="topicList">
                                @Power.ArticleList("文章头条列表", new {Node =childNode.Identifier, Count = 8, TitleLength = 80, TopicNum = 1, TopicTitleLength = 80, TopicContentLength = 160, TopicDisplayPic = false, DisplayDateTime="MM-dd", Sort="Priority,PublishTime", refnode = true })
                            </ul>
                        </div>
                    }
                    else if(childNode.ExtendObject.zslx=="图片")
                    {
                        <div class="pic-focus" id="box-@(childNode.Identifier)">
                            <a href="nojavascript...;" class="prev">&lt;</a>
                            <a href="nojavascript...;" class="next">&gt;</a>
                            <ul class="picList swiper-wrapper">
                                @Power.ArticleList("文章图片列表" , new {Count=10, Node=childNode.Identifier, TitleLength=60, ImageWidth=290, ImageHeight=580,refnode = true })
                            </ul>
                        </div>
                        <script>
                            $("#box-@(childNode.Identifier) li").addClass("swiper-slide");
                            var picSwiper = new Swiper ('#box-@(childNode.Identifier)', {
                                autoplay: true,//自动播放
                                loop: true, // 循环模式选项
                                initialSlide: 1,//滚动个数
                                slidesPerView:4,//可视个数
                                spaceBetween: 10,
                                // 如果需要前进后退按钮
                                navigation: {
                                    nextEl: '.next',
                                    prevEl: '.prev',
                                },
                                breakpoints: {
                                    1280: {  //当屏幕宽度小于等于1280
                                        slidesPerView: 3,
                                    },
                                    768: {  //当屏幕宽度小于等于768
                                        slidesPerView: 2,
                                    },
                                    320: {  //当屏幕宽度小于等于320
                                        slidesPerView: 1,
                                    }
                                }
                            });
                            $('#box-@(childNode.Identifier)').mouseenter(function () {
                                //鼠标停留时暂停自动播放
                                picSwiper.autoplay.stop();
                            })
                            $('#box-@(childNode.Identifier)').mouseleave(function () {
                                //鼠标离开是继续自动播放
                                picSwiper.autoplay.start();
                            })
                        </script>
                    }
                    else if(childNode.ExtendObject.zslx=="图文")
                    {
                        <ul class="topHasPicList">
                            @Power.ArticleList("文章头条列表-时间后置式", new {Node =childNode.Identifier, Count = 8, TitleLength = 80, TopicNum = 2, TopicTitleLength = 80, TopicContentLength = 100, TopicDisplayPic = true, ImageWidth=300, ImageHeight=200, DisplayDateTime="MM-dd", Sort="Priority,PublishTime", refnode = true })
                        </ul>
                    }
                    else{
                        <ul class="infoList">
                            @Power.ArticleList("文章标题列表", new {Node =childNode.Identifier, Count = 6, TitleLength = 110, ShowDate = true, DateFollowTitle=true, DateFormat = "MM-dd" })
                        </ul>
                    }
                }
            </dd>
        </dl>
    }
}



×

用户登录