DMXzone App Connect Support Product Page

Answered

conditions

Asked 10 Mar 2018 09:26:44
1
has this question
10 Mar 2018 09:26:44 andrea mac posted:
Hi, I want to set up a condition.
This is the matter:
I have a details page very simpple, a name and an image. In the insert form on the insert page, the image is not compulsory so there should be name without image.
In the details page this is ths schema for the image source (dynamic atribute):
if is there an image url in the image_url field
then img src = value inserted into the database
else
img src= default string

Can someone help me?

Thank you

Replies

Replied 12 Mar 2018 14:38:07
12 Mar 2018 14:38:07 Teodor Kuduschiev replied:
Hello Adrea,
Just use the default filter, to set the default value when no value is returned from the db.
Replied 25 Apr 2018 06:54:55
25 Apr 2018 06:54:55 Charles Knight replied:
What default filter, where is it?

I have an <img src="" dmx-bind:src="uploads/sm_{{$value[0].image_name}}" dmx-show="$value[0].image_name"/>

This works OK with the show but I would like to display a default image instead if no image is found in the database.

Please can you explain (in detail) how this is done or point me to a tutorial please?

Replied 25 Apr 2018 06:59:18
25 Apr 2018 06:59:18 Teodor Kuduschiev replied:
Replied 25 Apr 2018 08:20:15
25 Apr 2018 08:20:15 Charles Knight replied:
This does not work for me as I have used data binding template which allows me to use static and dynamic elements together:

If I click the data formatter I get an error message 'Live View alert' - Unknow variable and then it gives the static part of the binding template.

If I delete the static parts then the formatter works OK but reurns the data binding withou the data field in {{}}, if I then add back in the static elements the result fails.

Working Img Src;

<img src="" dmx-bind:src="uploads/sm_{{$value[0].image_name}}" dmx-show="$value[0].image_name"/>

after using the data formatter which does not return any images, note I have also removed the 'show' filter as it should not now be needed.

<img src="" dmx-bind:src="uploads/sm_$value.default(&quot;uploads/default.jpg&quot[0].image_name" />

Have tried wrapping the data binding in {{}} but still wont show any results

<img src="" dmx-bind:src="uploads/sm_{{$value.default(&quot;uploads/default.jpg&quot[0].image_name}}" />


The $Value is a group by I have to only show one record if the user has more than one image in the database.

Replied 25 Apr 2018 08:24:40
25 Apr 2018 08:24:40 Teodor Kuduschiev replied:
All you need to do is to use:

dmx-bind:src="uploads/sm_{{$value[0].image_name.default('default.jpg')}}"


The issue here is with your prefix "sm_" as if there is no data returned by the dynamic binding, the expression will render like:

uploads/sm_default.jpg

So please name your default image like "sm_default.jpg" and use the expression i provided above.
This reply was removed on 4/25/2018 9:03:11 AM.
See the changelog
Replied 25 Apr 2018 09:03:38
25 Apr 2018 09:03:38 Charles Knight replied:
Perfect!

Thanks you

Reply to this topic