Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > 'For loop' for image gallery View modes: 
User avatar
Certified Developer 10
Certified Developer 10
varinder-kudosweb - 7/7/2011 4:34:45 AM
   
'For loop' for image gallery
Hi all,
heres the situation: i was working on a project which shows a list of products (repeater) in a nice style (transformation) and details about a product can be seen by clicking it (selected transformatiom).

now in the products details page (selected transformation) there is a small light-box image gallery which shows pictures of the product (so far so good) but the problem is back-end, on the back-end, client is given 12 image upload input-boxes (which isnt really a user friendly option). Then on the products details page (selected transformation) theres a repeater which checks all those 12 fields for that product and spits out appropreate lightbox code for all the fields which were not empty but the way this repeater's transformation code was written (which really takes the point of having a repeater off the table). was something like (not on my computer so hardly remember what the exact code was)..

<%# ifEmpty(eval("image1"), "", <a href=.....) #> <br/>
<%# ifEmpty(eval("image2"), "", <a href=...)#> <br/>
......... so on to image12.

it works but it really got me wondering if theres any other approach. i mean, is it possible to create some kind of for loop which goes throught all those fields and shows gallery?

something like
for i=1 to 12 do (
ifempty(eval("image". i), "" .....)
) (excuse my messed up programming knowledge)

hope it makes sense :)

User avatar
Member
Member
kentico_michal - 7/10/2011 2:53:34 AM
   
RE:'For loop' for image gallery
Hello,

Regrettably, it is not possible to use for statement in the transformation, therefore you will need to execute Eval method for each image field. However, you could consider using standard unsorted attachments (Attachments example) and then you can use display them by adding one of the following two controls directly into the transformations:
~/CMSAdminControls/Attachments/DocumentAttachments.ascx
~/CMSAdminControls/Attachments/AttachmentLightboxGallery.ascx


More information can be found here: Handling attachments in transformations


Best regards,
Michal Legen

User avatar
Member
Member
lancetek - 7/10/2011 10:27:39 AM
   
RE:'For loop' for image gallery
Hi,
Or alternatively, you could add a Custom Function to encapsulate the loopy logic and return a Html string of the image list.

Lance