Categories > TinyButStrong general >

condition with image

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Peter
Date: 2003-08-18
Time: 13:39

condition with image

i use in my template the following:

[beitrag.bild;if [val]!='';then '<img align="right" src="uploads/[beitrag.bild]">']

i want to display the image if the field beitrag.bild is not empty. Whats wrong with my line?

Thanks Peter
By: Skrol29
Date: 2003-08-19
Time: 01:45

Re: condition with image

Hello Peter,

They are several things to say.

First your image will never display if you don't specifay 'htmlconv=no' in the main field because your <img> tag will be converter into HTML.

There is another problem : the expression [val]!='' can be false only if [val] is a string equale to "''" which is not an empty string.
If you want to check for a empty string, you have to write : '[val]'!=''
I agree this is absolutly not obvious. I should put warnings in the manual and in the FAQ.

But it is not the bottom : TBS fields don't perfom self-inclusion. You can include fields in orther fields but if it is the same field it doesn't work. This is a protection I have implemented to avoid infinite loops. I maybe should change that into a maximum number of loop.

But don't worry. TBS has what you need. The 'friend' parameter.
It is ingeneered specificaly for your need.
In your case, 'friendb' is maybe more apropriate.
<img align="right" src="uploads/[beitrag.bild;friendb=img]">
The image will display only if [beitrag.bild] is not empty.