7

I am using UGC feature of Tridion 2011. I have done almost but stuck in one place. actually, i have to display one text when user have entered comments, it will display if comments are greater then 0. i am using for this condition but it does not go in the condition.

<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> 

Could any one please help me to resolve his issue

vikas kumar
  • 2,444
  • 15
  • 25
Priyank Gupta
  • 942
  • 1
  • 7
  • 26
  • 1
    Can you clarify please? What do you see when you request the page, html1, html2 or nothing? Also, have you tried moving the Choose element outside the ItemStats element? Does the condition get executed then? – Quirijn Aug 20 '12 at 10:29
  • Actually, if comments is greater than 0 then i want to display HTML1 code, and if condition is false then want to display HTML2 code, i can not use Choose element outside the Itemstats because, i am using ugcItemStats.numberOfComments value to get the number of comments count. – Priyank Gupta Aug 20 '12 at 10:42
  • But what are you seeing at the moment? Nothing? – Quirijn Aug 20 '12 at 11:06

2 Answers2

9

Use this code, i hope will be work.

<%
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> 
Shekhar Gigras
  • 654
  • 3
  • 5
  • So the operation is performed with a variable set in the HttpContext Current Items? This is required? – Arjen Stobbe Aug 20 '12 at 11:55
  • 1
    as per the tridion help doc "The expression to evaluate; specifically, a comparison of context variables (pagecontext variables in JSP, or variables from HttpContext.Current.Items in .NET)" but it's working with equals . Help document heading 'If-then-clause in conditional" under UCG Command – Shekhar Gigras Aug 20 '12 at 11:59
1

The When statement accesses the ugcItemStates object from the HttpContext.Current.Items collection.

I suspect that by nesting the statement in the ItemStats control causes this object not to be available yet.

Arjen Stobbe
  • 1,684
  • 9
  • 15