【问题标题】:How to show only document types items which contains images in cms repeater - Kentico CMS如何在 cms 中继器中仅显示包含图像的文档类型项目 - Kentico CMS
【发布时间】:2013-12-06 16:19:09
【问题描述】:

我的文档类型 Product 包含以下字段:图像和文本。我想使用显示所有文档产品的 CMS 转发器将 webpart 添加到 kentico,但我只想显示包含图像的文档(不需要字段图像)。我添加了一行

WhereCondition="图像不为空"

到 cmsrepeater 并在我的本地计算机上运行 - 我只能看到带有图像的项目。但是当我将文件移动到暂存时,这是一个问题,我可以看到应该是图像的空白位置,所以我的方法不起作用,但我不知道为什么......有什么想法吗?

我所有的代码:

<cms:CMSRepeater ID="rptProducts" runat="server"
                 Path="/Products/%" 
                 ClassNames="Products.Item" 
                 TransformationName="Product.ProductList"
                 SelectOnlyPublished="true" 
                 StopProcessing="true"
                 PagerControl-PageSize ="4"
                 PagerControl-PageNumbersSeparator=""
                 PagerControl-BackNextStyle="display:none;"
                 EnablePaging="true"
                 ZeroRowsText='<%# CMS.GlobalHelper.ResHelper.GetString("ZeroRowsText") %>' 
                 WhereCondition="Image is not null" 
    />

我检查过,我的暂存站点没有缓存,所有文件都正确。

【问题讨论】:

  • 只是一个长镜头,但你可以尝试检查一个空字符串... ISNULL(Image, '') ''

标签: c# asp.net webforms kentico


【解决方案1】:

根据 Product 文档类型的 Image 字段的约束,该列是否可能包含空白值而不是 null 值?尝试添加一个额外的 where 条件检查该字段是否为空或为空。

<cms:CMSRepeater ID="rptProducts" runat="server"
                 Path="/Products/%" 
                 ClassNames="Products.Item" 
                 TransformationName="Product.ProductList"
                 SelectOnlyPublished="true" 
                 StopProcessing="true"
                 PagerControl-PageSize ="4"
                 PagerControl-PageNumbersSeparator=""
                 PagerControl-BackNextStyle="display:none;"
                 EnablePaging="true"
                 ZeroRowsText='<%# CMS.GlobalHelper.ResHelper.GetString("ZeroRowsText") %>' 
                 WhereCondition="Image IS NOT NULL AND Image <> ''" 
    />

【讨论】:

    猜你喜欢
    • 2013-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多