Developer forum

Forum » Templates » If Defined tags with custom fields

If Defined tags with custom fields


Reply
I have a customfield called AdImage and  have this testcode in a productlist template (code is below) . Its inside a related groups loop. In that loop there are two products. One product with the field "AdImage" defined and one where its not.
So the output should be:

(Annons)
(PDF)

But its not. The output is :

(PDF)
(PDF)

The funny thing is that i I ad an DwTemplateTags tag to the template inside the loop. The output is correct. And again wrong if I remove it.
Any ideas?

<!--@If Defined(Ecom:Product:Field.AdImage.Value)-->
(Annons)
<!--@EndIf(Ecom:Product:Field.AdImage.Value)-->
 
<!--@If Not Defined(Ecom:Product:Field.AdImage.Value)-->
(PDF)
<!--@EndIf(Ecom:Product:Field.AdImage.Value)-->



Regards / Aki

 

Replies

 
Nicolai Høeg Pedersen
Reply
Seems like an error in our implementation... I'll have it bugged.
 
Nicolai Høeg Pedersen
Reply
Oh - not a bug...

Problem is, that you need the tag Ecom:Product:Field.AdImage.Value somewhere in your template inside the loop.

So if you do like this, it should work:
!--@If Defined(Ecom:Product:Field.AdImage.Value)-->
(Annons)!--@Ecom:Product:Field.AdImage.Value-->
!--@EndIf(Ecom:Product:Field.AdImage.Value)-->
 
!--@If Not Defined(Ecom:Product:Field.AdImage.Value)-->
(PDF)
!--@EndIf(Ecom:Product:Field.AdImage.Value)-->
 
Lars Larsen
Reply

I had the same problem. But my custom tag is only used as a flag. I didn't want the tag value to be outputed on the page. To avoid that I added my own custom html data-flag tag with the customtag. Because my page is a HTML5 page I could use a custom html tag to make a workaround:


<!--@If Defined(MyCustomFlag)-->
<li><img src="/files/templates/designs/summitshop/img/prod/new.png" width="14" height="14" data-flag="<!--@MyCustomFlag-->"/></li>
<!--@EndIf(MyCustomFlag)-->

 
Lars Larsen
Reply

But couldn't you fix the problem, so that customtags are collected even though they are only used in DW if-tags?
 
Merethe Nielsen
Reply

Hi

It is registered in 6808:

Workaround:
Insert Dwtemplatetags in a hidden DIV or use the tag outside the statement (maybe in a hidden DIV too).

<div style="visibility:hidden"><!--@Ecom:Product:Field.Checktest.Value--></div> 
<!--@If(Ecom:Product:Field.Checktest.Value='True')-->
     HELLO
 <!--@EndIf-->
 
<div style="visibility:hidden"><!--@Ecom:Order.PriceWithoutFees.PricePIP--></div> 
<!--@If(Ecom:Order.PriceWithoutFees.PricePIP<100000)-->
     HELLO
 <!--@EndIf-->

 

You must be logged in to post in the forum