List of pictures in HTML

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
srufini
Posts: 34
Joined: Thu May 23, 2019 11:23 pm

List of pictures in HTML

Post by srufini »

Hello everyone,

I have a BO "Inspections" with an attribute "Inspections.Pictures" , where this attributes has multiple relationship to the BO "Album".
The BO "Album.Photos" contains the actual picture. The pictures are stored in file system.
I also added a "Album.URL" field where the actual path is saved.

In a form of "Inspections" I would like to show in a HTML section the list of all the pictures in "Inspection.Pictures"

I tried already with LIST or LIST_TABLE but no luck.
I wanted to insert HTML tag something like that:

<<LIST(Inspections.Pictures, 'Photo ', 'Title', 'Caption')>>
OR
<<LIST(Inspections.Pictures, '<img src="URL"> ', 'Title', 'Caption')>>

but no luck.

Any suggestion?

Thanks

Sergio
joben
Posts: 230
Joined: Wed Nov 06, 2019 9:49 pm
Location: Sweden
Contact:

Re: List of pictures in HTML

Post by joben »

Insert the Pictures attribute in the Inspections form.
Change the Widget for Pictures to "Custom list" and use {Photo} to refer to the photo attribute.
I think that should work.
Regards, Joakim

Image
srufini
Posts: 34
Joined: Thu May 23, 2019 11:23 pm

Re: List of pictures in HTML

Post by srufini »

Thanks Joben,

however, I am not satisfied on how the custom list works for my application.
I want to use in the same form section a view mode and a edit mode of this pictures attribute. I am not allowed to have an attribute two times in the same section and therefore I wanted to try to use a "print out" of the pictures when in view mode, and a grid widget when in edit mode.

Cheers

Sergio
PointsWell
Posts: 1460
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: List of pictures in HTML

Post by PointsWell »

You need two forms. An edit form and a view form.
srufini
Posts: 34
Joined: Thu May 23, 2019 11:23 pm

Re: List of pictures in HTML

Post by srufini »

PointsWell wrote: Sat Dec 16, 2023 1:38 am You need two forms. An edit form and a view form.
Thanks PointsWell,

this is the only solution I know now, and the one I would like to avoid.
I guess then that embedding a list of pictures in HTML is not feasible?
PointsWell
Posts: 1460
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: List of pictures in HTML

Post by PointsWell »

srufini wrote: Mon Dec 18, 2023 1:20 pm
PointsWell wrote: Sat Dec 16, 2023 1:38 am You need two forms. An edit form and a view form.
Thanks PointsWell,

this is the only solution I know now, and the one I would like to avoid.
I guess then that embedding a list of pictures in HTML is not feasible?
It is possible, you need to make a custom query. See the CRM and Sales Portal examples.

You just can't have the same element showing twice - so if you want it to be in different formats in edit and read mode you will need to create two forms.
joben
Posts: 230
Joined: Wed Nov 06, 2019 9:49 pm
Location: Sweden
Contact:

Re: List of pictures in HTML

Post by joben »

srufini wrote: Mon Dec 18, 2023 1:20 pm
PointsWell wrote: Sat Dec 16, 2023 1:38 am You need two forms. An edit form and a view form.
Thanks PointsWell,

this is the only solution I know now, and the one I would like to avoid.
I guess then that embedding a list of pictures in HTML is not feasible?
There are two ways I am thinking of that could work if you really want it to be in the same form. I can't really recommend it because they are a bit complicated.

1. You could create a text attribute (content: HTML) with a large max length. Let's call it PicturesHTMLfield.
Then use update rules to loop through all the related pictures and store it in an HTML table structure in this field. Then you can display the attribute in the form like: <<Inspections.PicturesHTMLfield>>

2. The other way I am thinking of is to have two separate relations to the Pictures BO. Like:

Inspections.Pictures
and
Inspections.PicturesHTML

Then you let update rules handle it so that if a picture is related via the Inspections.Pictures path, you make sure to INSERT that object in Inspections.PicturesHTML as well.
Then you should be able to display the attribute PicturesHTML and set it to a custom list, and it will not collide with your original Pictures attribute in the same form.
Regards, Joakim

Image
srufini
Posts: 34
Joined: Thu May 23, 2019 11:23 pm

Re: List of pictures in HTML

Post by srufini »

joben wrote: Tue Dec 19, 2023 7:32 am
srufini wrote: Mon Dec 18, 2023 1:20 pm
PointsWell wrote: Sat Dec 16, 2023 1:38 am You need two forms. An edit form and a view form.
Thanks PointsWell,

this is the only solution I know now, and the one I would like to avoid.
I guess then that embedding a list of pictures in HTML is not feasible?
There are two ways I am thinking of that could work if you really want it to be in the same form. I can't really recommend it because they are a bit complicated.

1. You could create a text attribute (content: HTML) with a large max length. Let's call it PicturesHTMLfield.
Then use update rules to loop through all the related pictures and store it in an HTML table structure in this field. Then you can display the attribute in the form like: <<Inspections.PicturesHTMLfield>>

2. The other way I am thinking of is to have two separate relations to the Pictures BO. Like:

Inspections.Pictures
and
Inspections.PicturesHTML

Then you let update rules handle it so that if a picture is related via the Inspections.Pictures path, you make sure to INSERT that object in Inspections.PicturesHTML as well.
Then you should be able to display the attribute PicturesHTML and set it to a custom list, and it will not collide with your original Pictures attribute in the same form.
1> this have already done. What I am missing if what HTML code I should put to print the LIST of these pictures using the URL code and list function. Somthing like:
<<LIST(Inspections.Pictures, <img src='URL'>, 'Title', 'Caption')>>
?? Any suggestion?

2> This is indeed my backup solution!

Thanks

Sergio
joben
Posts: 230
Joined: Wed Nov 06, 2019 9:49 pm
Location: Sweden
Contact:

Re: List of pictures in HTML

Post by joben »

srufini wrote: Wed Dec 20, 2023 8:35 am 1> this have already done. What I am missing if what HTML code I should put to print the LIST of these pictures using the URL code and list function. Somthing like:
<<LIST(Inspections.Pictures, <img src='URL'>, 'Title', 'Caption')>>
?? Any suggestion?

2> This is indeed my backup solution!

Thanks

Sergio
I am not sure if the LIST function is even compatible with pictures.
I would do something like this:

Update Rule in inspections BO:
FIND Pictures WHERE (Pictures.Inspections=Inspections) IN BATCHES OF 1
Inspections.PicturesHTML=Inspections.PicturesHTML+`<tr><td><<Pictures.Title>></td><td><img src='/path/to/folder/<<Pictures.Picture>>'/></td></tr>`

Then create another rule so that the PicturesHTML attribute has a table element:
Inspections.PicturesHTML='<table>'+Inspections.PicturesHTML+'</table>'

I have not tested any of this code, but the main ingredient of using "IN BATCHES OF 1" to build a loop should absolutely work.
Performance and making sure the PicturesHTML field is always up to date will be something you will have to consider.
Regards, Joakim

Image
srufini
Posts: 34
Joined: Thu May 23, 2019 11:23 pm

Re: List of pictures in HTML

Post by srufini »

Thank you!
I will give it a try.

Ciao

Sergio
joben wrote: Wed Dec 20, 2023 10:24 am
srufini wrote: Wed Dec 20, 2023 8:35 am 1> this have already done. What I am missing if what HTML code I should put to print the LIST of these pictures using the URL code and list function. Somthing like:
<<LIST(Inspections.Pictures, <img src='URL'>, 'Title', 'Caption')>>
?? Any suggestion?

2> This is indeed my backup solution!

Thanks

Sergio
I am not sure if the LIST function is even compatible with pictures.
I would do something like this:

Update Rule in inspections BO:
FIND Pictures WHERE (Pictures.Inspections=Inspections) IN BATCHES OF 1
Inspections.PicturesHTML=Inspections.PicturesHTML+`<tr><td><<Pictures.Title>></td><td><img src='/path/to/folder/<<Pictures.Picture>>'/></td></tr>`

Then create another rule so that the PicturesHTML attribute has a table element:
Inspections.PicturesHTML='<table>'+Inspections.PicturesHTML+'</table>'

I have not tested any of this code, but the main ingredient of using "IN BATCHES OF 1" to build a loop should absolutely work.
Performance and making sure the PicturesHTML field is always up to date will be something you will have to consider.
Post Reply