我的文档类型为产品,其字段为:图像和文本。我想使用 CMS 中继器将 webpart 添加到 kentico,以显示所有文档产品,但我想仅显示包含图像的文档(不需要字段图像)。我添加了一行
WhereCondition="Image is not null"
到 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" />
我已经检查过,我的暂存网站没有被缓存,并且所有文件都是正确的。
最佳答案
根据产品文档类型的图像字段的约束,该列是否可能包含空白值而不是空值?尝试添加额外的 where 条件检查字段是否为 null 或为空。
<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 <> ''"
/>
关于c# - 如何在 cms Repeater 中仅显示包含图像的文档类型项目 - Kentico CMS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20428666/