【问题标题】:UGC conditional statement is not workingUGC 条件语句不起作用
【发布时间】:2012-08-15 15:30:47
【问题描述】:

我正在使用 Tridion 2011 的 UGC 功能。我几乎完成了,但卡在了一个地方。实际上,当用户输入 cmets 时,我必须显示一个文本,如果 cmets 大于 0,它将显示。我正在使用此条件,但它不符合条件。

<ugc:ItemStats  ItemURI="@PhysicalUri" runat="server">
<ugc:Choose runat="server">
  <ugc:When test=" ugcItemStats.numberOfComments equals  0 " runat="server">
       html1
  </ugc:When>
  <ugc:Otherwise runat="server"> 
       html2
  </ugc:Otherwise> 
</ugc:Choose>
</ugc:ItemStats> 

谁能帮我解决他的问题

【问题讨论】:

  • 你能澄清一下吗?当您请求页面时,您会看到什么,html1、html2 还是什么都没有?另外,您是否尝试过将选择元素移到 ItemStats 元素之外?那么条件会被执行吗?
  • 实际上,如果 cmets 大于 0 则我想显示 HTML1 代码,如果条件为 false 则想显示 HTML2 代码,我不能在 Itemstats 之外使用选择元素,因为我正在使用ugcItemStats.numberOfComments 值获取 cmets 计数。
  • 但是你现在看到了什么?什么都没有?

标签: tridion tridion-2011 ugc


【解决方案1】:

使用这个代码,我希望它会起作用。

<%
HttpContext.Current.Item["variable"] = 0;
%>

<ugc:ItemStats  ItemURI="@PhysicalUri" runat="server">
<ugc:Choose runat="server">
  <ugc:When test="ugcItemStats.numberOfComments equals  variable " runat="server">
       html1
  </ugc:When>
  <ugc:Otherwise runat="server"> 
       html2
  </ugc:Otherwise> 
</ugc:Choose>
</ugc:ItemStats> 

【讨论】:

  • 那么操作是用HttpContext Current Items中设置的变量来执行的?这是必需的吗?
  • 根据 tridion 帮助文档“要评估的表达式;特别是上下文变量(JSP 中的 pagecontext 变量,或 .NET 中 HttpContext.Current.Items 的变量)的比较”,但它正在使用等于 。 UCG 命令下的帮助文档标题“条件条件中的 If-then-clause”
【解决方案2】:

When 语句从 HttpContext.Current.Items collection 访问 ugcItemStates 对象。

我怀疑将语句嵌套在 ItemStats 控件中会导致该对象尚不可用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-01-08
    • 2011-12-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多