Developer forum

Forum » Templates » If tags with @GetMaster()

If tags with @GetMaster()

Martin Nielsen
Reply
Hi DW,

I'm trying to make a related products groups loop, and i'd like to filter out some of the groups in the loop.

I have a product that has 3 related groups:
 - Variants (GRP1)
 - Related products (GRP2)
 - You might like (GRP3)

And i don't want to render "Variants" group in my loop. Since my templates have to be highly resuable i dont want to hardcode any group id's into the template, instead i created a custom tag that contains the group i don't want to render.

My snippet looks like this without the If filter, and renders all groups:

  <!--@LoopStart(ProductRelatedGroups)-->
  <div class="featured productlist">
    <h6 class="theme gradient"><!--@Ecom:Product:RelatedGroup.Name--></h6>
    <ul class="productlist rowsview">
    <!--@LoopStart(RelatedProducts)-->
      <!--@Include(../ProductList/item/item.html)-->
    <!--@LoopEnd(RelatedProducts)-->
    </ul>
  </div>
  <!--@LoopEnd(ProductRelatedGroups)-->
I could do this, if i wanted to hardcode the group id:
  <!--@LoopStart(ProductRelatedGroups)-->
  <!--@If(Ecom:Product:RelatedGroup.GroupID!='GRP1')-->  
  <div class="featured productlist">
    <h6 class="theme gradient"><!--@Ecom:Product:RelatedGroup.Name--></h6>
    <ul class="productlist rowsview">
    <!--@LoopStart(RelatedProducts)-->
      <!--@Include(../ProductList/item/item.html)-->
    <!--@LoopEnd(RelatedProducts)-->
    </ul>
  </div>
  <!--@EndIf-->  
  <!--@LoopEnd(ProductRelatedGroups)-->
But i dont want that, so i figured i could do as the snippet below, where i use the new DW8 tag @GetMaster() to get the value from outside my loop:

  <!--@LoopStart(ProductRelatedGroups)-->
  <!--@If(Ecom:Product:RelatedGroup.GroupID!=GetMaster(Co3.RelatedGroupID.I.Dont.Want.To.Render))-->  
  <div class="featured productlist">
    <h6 class="theme gradient"><!--@Ecom:Product:RelatedGroup.Name--></h6>
    <ul class="productlist rowsview">
    <!--@LoopStart(RelatedProducts)-->
      <!--@Include(../ProductList/item/item.html)-->
    <!--@LoopEnd(RelatedProducts)-->
    </ul>
  </div>
  <!--@EndIf-->  
  <!--@LoopEnd(ProductRelatedGroups)-->
Where "<--@Co3.RelatedGroupID.I.Dont.Want.To.Render-->" contains the ID of the group i don't want to render.

But the last snippet here breaks my site.

Is my snippet wrong, or does @If() not support @GetMaster() yet?


Regards
  Martin

Replies

 
Nicolai Høeg Pedersen
Reply
You cannot use GetMaster in the if...

You could use XSLT.... or use the Ecom:Product:RelatedGroup.GroupID as a class on the containing div and use CSS to hide the output... Ugly, I know.
Or make a small product template extender.

 

You must be logged in to post in the forum