Developer forum

Forum » Templates » If:Defined show=Custom product field

If:Defined show=Custom product field


Reply

How come this aint working for me :( ?

 

 

/*<!--@If Defined(Ecom:Product:Field.Nyhed.Template)-->
    <img src="files/Billeder/Champagneslottet/k_nyhed.gif"> 
    <!--@EndIf(Ecom:Product:Field.Nyhed.Template)-->
<!--DwTemplateTags-->
    <!--@If Not Defined(Ecom:Product:Field.Nyhed.Template)-->
    <img src="blank.gif"> 
    <!--@EndIf(Ecom:Product:Field.Nyhed.Template)-->*/


Replies

 
Reply

NEVER MIND! :)

 

I needed to use the right tag:

Field.Nyhed.Value

 

   
Reply

Ahh that would have been useful.

 

Thanks anyway

 
Reply

Hehe... No problem:)

 
Reply
Sorensen wrote:

Hehe... No problem:)

On second thought.
 

At first this worked fine, but now it just ain't working at all :/

 

<div style="width:145px;height:25px;">
        <!--@If Defined(Ecom:Product:Field.Nyhed.Value)-->
    <img src="files/Billeder/Champagneslottet/k_nyhed.gif"> 
    <!--@EndIf(Ecom:Product:Field.Nyhed.Value)-->
    <!--@If Not Defined(Ecom:Product:Field.Nyhed.Value)-->
    <img src="blank.jpg"> 
    <!--@EndIf(Ecom:Product:Field.Nyhed.Value)-->
        </div>

 

And for the second question:

 

Iam trying to do a simple mouseover effect in a productloop:

 

Outside the loop it works fine, but within nothing happens. :(

 

<SCRIPT language="JavaScript">
function movepic(img_name,img_src) {
document[img_name].src=img_src;
}
</SCRIPT>

 

 

<A HREF="/default.aspx?id=<!--@Ecom:Product:Page.ID-->&amp;productid=<!--@Ecom:Product.ID-->&amp;cartcmd=add" onmouseover="movepic('button','files/Billeder/Champagneslottet/k_koeb_over.gif')" onmouseout="movepic('button','files/Billeder/Champagneslottet/k_koeb.gif')">
<IMG NAME="button" SRC="files/Billeder/Champagneslottet/k_koeb.gif" ALT="Image"></A>

 

 
Reply

Sometimes sub tags aren't parsed, unless you use the main tag. So Ecom:Product:Field.Nyhed.Value may not be parsed, if you don't have the Ecom:Product:Field.Nyhed tag in your template. Do one of the following:

 

 - Use Ecom:Product:Field.Nyhed in your If Defined

 - Place the Ecom:Product:Field.Nyhed in a hidden div and use Ecom:Product:Field.Nyhed.Value in your If Defined as you do now.

 

For the second question, compare the output HTML of the one that works and the one that doesn't work.

 
Reply

Thanks for your quick reply.

 

Both suggestions didn't do the trick for me. :(

 
Reply

Weird... Are you sure the tag is available in the given context? <!--@DwTemplateTags-->

 

 

I've sometimes spent a bit too much time on issues like that, and then it turned out that I was using incorrect casing:) Could that be the issue?

 

Could you show it on a live solution I can access?

 
Reply
Sorensen wrote:

Weird... Are you sure the tag is available in the given context? <!--@DwTemplateTags-->

 

 

I've sometimes spent a bit too much time on issues like that, and then it turned out that I was using incorrect casing:) Could that be the issue?

 

Could you show it on a live solution I can access?

Yes iam quit sure :)
 

 

The solution is on http://kontinuum.net.dynamicweb.dk/Default.aspx?ID=79&Purge=True

 

Do you have angle-access or ?

 
Reply

Ah, now I think I know, what's bothering you. It's a boolean value, and you assume that when not checking the checkbox, it will match Not Defined, right? If so, the out put values are:

 

Checked: True

Un-checked: False

 

But it will always be defined.

 

You can do the trick by using a text input field (or perhaps a drop down - not sure). Or you can use JavaScript to display the right picture:

 

if ("<!--@Ecom:Product:Field.Nyhed.Value--> == "True"){

//Nyhed

}else{

//Ikke nyhed

 
Reply

Great. Thanks alot.

 

All problems solved.

 

Almost.. :)

 

Iam trying to follow Sebastians exemple on how to add more then one item to the basket.

 

But when i copy paste his code I get a javascript error.

 

http://developer.dynamicweb.dk/default.aspx?id=16918&action=ShowArticle&ArticleID=98

 

Any good ideas?

 
Reply

No problem.

 

Sebastian's example assume that you're using a form for each product displayed on the page, and you're not.

 

Your add-to-basket button is trying to submit a non-existing form called "79&productid=PROD6&cartcmd=add", which is what actually provokes the JavaScript error.

 

The trick is simply to apply the quantity parameter to the http request. You could do something like this instead:

 

<form name="<!--@Ecom:Product.ID-->" method="get">

<input type="hidden" name="ProductID" value="<!--@Ecom:Product.ID-->" />

<input type="hidden" name="cartcmd" value="add" />

<input type="text" name="quantity" value="1" />

</form>

 

Then your add-to-basket link would be <a href="javascript:void(0);" onclick="document.getElementById('<!--@Ecom:Product.Id-->').submit();">Add to basked</a>

 

You'll have to make a form for each product, so do this within the product collection loop in the product list template.

 
Reply

The input box works fine, but there is still an issue with the submitting script.

 
Reply

I got it!

 

You used a small d in <!--@Ecom:Product.ID-->..

 

It now works like a charm.

 

Thanks again Lars

 
Reply

Woops, sorry:) No problem!

 

You must be logged in to post in the forum