UGC conditional statement is not working
Asked Answered
D

2

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

Dollfuss answered 20/8, 2012 at 9:38 Comment(3)
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?Parapsychology
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.Dollfuss
But what are you seeing at the moment? Nothing?Parapsychology
R
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> 
Rheumy answered 20/8, 2012 at 11:25 Comment(2)
So the operation is performed with a variable set in the HttpContext Current Items? This is required?Costotomy
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 CommandRheumy
C
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.

Costotomy answered 20/8, 2012 at 10:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.