This question about Topic Markup Language and applications: Answered

Generate list of uploaded images for select field

I have following fields defined in my DataForm:

| Image1 | text | 150 | | | |
| Image2 | text | 150 | | | |
| Image3 | text | 150 | | | |
| ImageCaption1 | textarea | 250x3 | | | |
| ImageCaption2 | textarea | 250x3 | | | |
| ImageCaption3 | textarea | 250x3 | | | |

where Image1, Image2 and Image3 are names of attached (to current topic) images.

They're used as follows in view template:

%IF{"'%FORMFIELD{"Image1"}%'!=''" then="%IMAGE{"%ATTACHURL%/%FORMFIELD{"Image1"}%" type="frame" align="right" caption="%FORMFIELD{"ImageCaption1"}%"}%"}%

%IF{"'%FORMFIELD{"Image2"}%'!=''" then="%IMAGE{"%ATTACHURL%/%FORMFIELD{"Image2"}%" type="frame" align="right" caption="%FORMFIELD{"ImageCaption2"}%"}%"}%

%IF{"'%FORMFIELD{"Image3"}%'!=''" then="%IMAGE{"%ATTACHURL%/%FORMFIELD{"Image3"}%" type="frame" align="right" caption="%FORMFIELD{"ImageCaption3"}%"}%"}%


Instead of typing name of the uploaded image in Image1, Image2 and Image3 fields, I would like to select appropriate file name from select field. However, I don't know how can I generate such list. Could you help me on this, please?

-- MateuszKDzior - 06 Nov 2015

I believe this achieves what you're describing:
| *Name*  | *Type* | *Size* | *Values* | *Tooltip message* | *Attributes* | 
| Image1 | select | 1 | ,%QUERY{"'%BASEWEB%.%BASETOPIC%'/attachments.name"}%  | | |
| Image2 | select | 1 | ,%QUERY{"'%BASEWEB%.%BASETOPIC%'/attachments.name"}%  | | |
| Image3 | select | 1 | ,%QUERY{"'%BASEWEB%.%BASETOPIC%'/attachments.name"}%  | | |
| Image Caption 1 | textarea | 250x3 | | | |
| Image Caption 2 | textarea | 250x3 | | | |
| Image Caption 3 | textarea | 250x3 | | | |

This creates a select element listing the attachments in the base topic. The leading comma is simply to provide a blank first option. You could refine the QUERY macro to only list certain kinds of files. e.g. %QUERY{"'Support.Question1717'/attachments[name ~ '*.jpeg'].name"}%

-- Main.LynnwoodBrown - 16 Nov 2015 - 15:23
 

QuestionForm edit

Subject Topic Markup Language and applications
Extension
Version Foswiki 2.0.2
Status Answered
Related Topics
Topic revision: r2 - 16 Nov 2015, LynnwoodBrown
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy