Developer forum

Forum » Ecommerce - Standard features » IF statements not doing as it should - must be a bug

IF statements not doing as it should - must be a bug

Hans Ravnsfjall
Hans Ravnsfjall
Reply

Hi, I have a problem getting the output that I want. After spending nearly 2 hours on this thing, my conclusion is that this must be a bug.

I have FACET loop that looks like this

[
 
<!--@LoopStart(FacetGroups)-->
    <!--@LoopStart(Facets)--><!--DwTemplateTags-->
        <!--@LoopStart(FacetOptions)-->

<font color="red"><!--@Facets.LoopCounter--></font> <!-- this is just an output to make shure that the value I am testing against on the line below actually is what I assume -->
<!--@If(FacetOptions.LoopCounter>1 || Facets.LoopCounter=2)-->,<!--@EndIf-->
{
{
    "name":"<!--@FacetOption.Label.JSEncoded()-->",
    "web": "http://www.skyn.fo?<!--@Facet.QueryParameter-->=<!--@FacetOption.Label.JSEncoded()-->",
    "resultcount": <!--@FacetOption.Count-->,
    "keywords": [
      
    ]
}
        <!--@LoopEnd(FacetOptions)-->
    <!--@LoopEnd(Facets)-->
<!--@LoopEnd(FacetGroups)-->


 ]

 

This outputs this result

[ 1 { { "name":"Argir", "web": "http://www.skyn.fo?City=Argir", "resultcount": 1, "keywords": [ ] } 1 , { { "name":"Sørvágur", "web": "http://www.skyn.fo?City=Sørvágur", "resultcount": 1, "keywords": [ ] } 1 , { { "name":"Toftir", "web": "http://www.skyn.fo?City=Toftir", "resultcount": 1, "keywords": [ ] } 1 , { { "name":"Tórshavn", "web": "http://www.skyn.fo?City=Tórshavn", "resultcount": 4, "keywords": [ ] } 1 , { { "name":"Tvøroyri", "web": "http://www.skyn.fo?City=Tvøroyri", "resultcount": 1, "keywords": [ ] } 1 , { { "name":"Velbastaður", "web": "http://www.skyn.fo?City=Velbastaður", "resultcount": 2, "keywords": [ ] } 2 { { "name":"Eysturoy", "web": "http://www.skyn.fo?District=Eysturoy", "resultcount": 1, "keywords": [ ] } 2 , { { "name":"Nólsoy og Heystur", "web": "http://www.skyn.fo?District=Nólsoy og Heystur", "resultcount": 1, "keywords": [ ] } 2 , { { "name":"Suðuroy", "web": "http://www.skyn.fo?District=Suðuroy", "resultcount": 2, "keywords": [ ] } 2 , { { "name":"Suðurstreymoy", "web": "http://www.skyn.fo?District=Suðurstreymoy", "resultcount": 5, "keywords": [ ] } 2 , { { "name":"Vágar", "web": "http://www.skyn.fo?District=Vágar", "resultcount": 1, "keywords": [ ] } ]

 

To my best knowledge, I should get a Comma seperator as soon as Facets.LoopCounter=2, but this is not the case. The Facets.LoopCounter does get the value 2 as i am optputting for debugging in my loop, but the IF statement doesn´t catch this.

Look at this picture http://www.screencast.com/t/7VTZCs4wnf

 

for reference, the output page is here http://skyn.dw9.dynamicweb-cms.com/Default.aspx?ID=13&Purge=True

 

 

 


Replies

 
Nicolai Pedersen
Reply

Hi Hans

I am not sure you can use the Facets.LoopCounter inside the FacetOptions loop when doing conditionals in HTML templates.

Attached a template that returns Facets in Json, written in Razor (Just remove the product list part). You then have to rename the json properties to your needs.

BR Nicolai

 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

Hi

If i can output it, should it not be possible to write an IF statement on it? I am outputting the value in the precise same context as where i am writing an IF statment on it. This because I want to add a comme where it shifts from the first facet list to the second.

 

 
Nicolai Pedersen
Reply

It is text based context parsing, and it would be nice if you could. But it cannot - and it would be a problem to solve it. That is one of the reasons we introduced Razor. To handle more "complicated" stuff in templates.

 

You must be logged in to post in the forum