DMXzone Database Connector PHP Support Product Page

Turning database number into file reference / build a text string.

Asked 05 Oct 2013 14:20:37
1
has this question
05 Oct 2013 14:20:37 Ruud Bouman posted:
Great extension! Saves me a lot of time. Just wondering if you have an idea to solve a problem. I am reading product data from a MySQL, Prestashop database. One of the tables contains the product image id's. The id refers to an image, stored in a folder. Each product has 6 different sized images, stored within the filename. For example: product 'X' has image id '47'. The images are stored in folder "<root>/img/p/4/7". Filenames are, for instance "47-home_default.jpg" and "47-medium_default.jpg". Now for the question: can i use Database Connector - Data Bindings Formatter to enrich the id '47' to a file reference, '/img/p/4/7/47-home_default.jpg" where the '4' and '7' are provided from the database (47)?

The whole idea is to create a custom, thumbnail slideshow to use on a different website, other then the Prestashop site.

Hope my question is clear, looking forward to hear from you,
Regards,
Ruud.

Replies

Replied 08 Oct 2013 10:43:54
08 Oct 2013 10:43:54 Teodor Kuduschiev replied:
Hello Ruud,

This is an interesting case. This is practically possible using the formatter with regular expressions. Something like:

src="/img/p/{{id.replace(/(\d)(\d)/, "$1/$2")}}/{{id}}-him_default.jpg"


Reply to this topic