Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UGC conditional statement is not working

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

like image 511
Priyank Gupta Avatar asked Aug 20 '12 09:08

Priyank Gupta


2 Answers

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> 
like image 115
Shekhar Gigras Avatar answered Oct 28 '22 12:10

Shekhar Gigras


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.

like image 28
Arjen Stobbe Avatar answered Oct 28 '22 12:10

Arjen Stobbe