【问题标题】:Can I make Orchard show the entirety of a blog post in the blog list?我可以让 Orchard 在博客列表中显示整个博客文章吗?
【发布时间】:2011-06-30 16:47:26
【问题描述】:

我刚刚设置了 Orchard,并注意到预览小部件仅显示带有标准“更多”链接的前几句话。有没有办法在不创建自定义小部件的情况下覆盖此功能?我希望 Orchard 展示我最近的五个帖子的全部内容。

【问题讨论】:

    标签: content-management-system orchardcms


    【解决方案1】:

    我想在不覆盖整个站点的 Common.Body.Summary 部分的情况下做类似的事情。我只希望 BlogPosts 将完整的 HTML 用于摘要。我想我已经通过将以下行添加到 Placement.info 来实现这一点:

    <Match ContentType="BlogPost">
        <Match DisplayType="Summary">
            <Place Parts_Common_Body_Summary="Content:after;Alternate=Parts_Common_Body"/>
        </Match>
    </Match>
    

    【讨论】:

    • 通过将属性 Path="/blog" 添加到 Match 元素中,我能够在博客页面上显示帖子的全文,同时在主页小部件中保留简短的摘要。
    【解决方案2】:

    当然,只要把这个 Parts.Common.Body.Summary.cshtml 放到你主题的views目录中:

    @{
        Orchard.ContentManagement.ContentItem contentItem = Model.ContentPart.ContentItem;
        var bodyHtml = new HtmlString(Model.Html.ToString());
    }
    
    <p>@bodyHtml</p>
    

    【讨论】:

    • 非常感谢。那很容易也很棒。我需要阅读更多文档,但我才刚开始接触 Orchard。
    • 非常感谢。这对我有用,我认为我必须在 Core\Views 中进行编辑,因为我的主题没有覆盖它。我还没有找到更好的解决方案。我很惊讶这还不是配置中的一个选项。感觉应该是这样。
    • @bertrand le roy:如何将 cmets 放入博客列表?我的意思是如何在每个帖子下面显示 cmets
    • 请将新问题作为新问题提出。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-18
    • 2020-02-25
    • 1970-01-01
    相关资源
    最近更新 更多