Developer forum

Forum » Feature requests » Check if files exists in a template

Check if files exists in a template

Tom-Erik Paulsen
Reply

Wouldn't it be cool to have a feature like this?

An easy way of checking if files excist in the file archive?


<!--@If Excists('/Files/productimages/800/<!--@Ecom:Product.Number-->.jpg')-->
    <img src="/Files/productimages/800/<!--@Ecom:Product.Number-->.jpg" />
<!--@EndIf-->

Or:

<!--@If Defined(FILE:/Files/productimages/800/<!--@Ecom:Product.Number-->.jpg)-->
   <img src="/Files/productimages/800/<!--@Ecom:Product.Number-->.jpg" />
<!--@EndIf-->


Replies

 
Morten Bengtson
Reply

You can do that in a razor template. See http://developer.dynamicweb.com/forum/templates/razor-check-if-image-exists.aspx

 
Tom-Erik Paulsen
Reply

I saw that post, but without razor knowledge, its kind of hard to do for designers. :-)

How would I go by adding a razor filter to an ecommerce product template?

 

could I use the razor code directly in the template?

 
Nicolai Høeg Pedersen
Reply

Hi Tom

If you use the GetImage handler (it has a UI in MC), you can specify an "Alternative" image that will be displayed if the file specified is not present.

See here: http://manual.dynamicweb-cms.com/Default.aspx?ID=7488

Nicolai

 
Tom-Erik Paulsen
Reply

Thanks!

The problem we are facing is if the product have pictograms in a specific folder.

If it has a pictogram, a default text is to be shown along with the image, and some other markup stuff and tags. So the Alternative image will not do in this matter.

It was just a suggestion, because we see a lot of  scenarios where this could come in handy. As of now, I can do this with javascript :-)