Developer forum

Forum » Ecommerce - Standard features » Index Facet looping not possible in html?

Index Facet looping not possible in html?

Hans Ravnsfjall
Hans Ravnsfjall
Reply

Hi

I am trying this html with no luck
<!--@LoopStart(FacetGroups)-->
    <!--@LoopStart(Facets)-->
        <!--@LoopStart(FacetsOptions)-->
            <!--@DwTemplateTags-->
        <!--@LoopEnd(FacetsOptions)-->
    <!--@LoopEnd(Facets)-->


<!--@LoopEnd(FacetGroups)-->

 

However this works fine in Razor

 

@foreach (LoopItem facetGroup in GetLoop("FacetGroups"))
{
        foreach (LoopItem facet in facetGroup.GetLoop("Facets"))
        {
        
                
                        
                        foreach (LoopItem option in facet.GetLoop("FacetOptions"))
                        {
                            var value = option.GetValue("FacetOption.Value");
                            var selected = option.GetBoolean("FacetOption.Selected");
                            var label = option.GetString("FacetOption.Label");
                            var count = option.GetInteger("FacetOption.Count");

                  @TemplateTags()
                           
                                
                        }
                    
               
        }
}   

 

 

Am i doing something wrong, or is it not possible to loop facets in html templates?

 

I want to use this to write a simple JSON, but keep getting an error in the Razor code. If it is not possible to loop facets in HTML templates, does someone have a Razor example that writes a facets based JSON file?

 

Thanks in advance.

Br, Hans

 


Replies

 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

Update Solved

 

The problem was that Dynamicweb removed my selected Facet in product catalog settings when I changed template.

 

So it was a GUI problem, and not a template problem

 
Nicolai Pedersen
Reply

ok. In your code above, you have written FacetsOptions whith an extra s. It is FacetOptions which is also what you use in your Razor.

BR Nicolai

 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

Perfect, Thank you Nicolai

was just wondering why I didnt get the output on the facets.

 

works perfectly now :)

 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

That said, it is really annoying that DW throws out my settings on the product catalog everytime at change a paragraphtemplate or productlisting template and so on.

 
Nicolai Pedersen
Reply

Hi Hans

It should not throw out your settings. Only if you delete/rename your search etc.

Which DW version and browser are you using?

 
Hans Ravnsfjall
Hans Ravnsfjall
Reply

Its a DW 9 (proably newest release?)

It´s this solution http://skyn.dw9.dynamicweb-cms.com/Admin/default

I am using FIrefox 50.02.

I have just created another case on a related problem where the IF handler, does not do as it should. I have tried everything, and my conclusion is that this must be a problem, because I am outputing the exact value that I am testing against, right before the IF statement, but the statement does not catch this.

regards, Hans

 
Nicolai Pedersen
Reply

Hi Hans

I cannot reproduce that in my FF, same version..

 

You must be logged in to post in the forum