3445 Posts in 1031 Topics by 872 members
|Go to End|
9 December 2010 at 10:02am Last edited: 9 December 2010 10:28am
is the following possible in a template using $Top and control loops?
I have two functions in my controler (extends Page_Controler).
getAlbumImages() ... returns a DataObject with all images contained in folder: assets/images/
getAlbumTitle($imageFile) ... should return a image description from the image filename
(XX_image_description_in_file.ext ==> image description in file)
In my template I use something like:
<% if getAlbumImages %>
<% control getAlbumImages %>
<a href="$URL" rel="album" title="$Title">$SetRatioSize(150,150)</a>
<% end_control %>
<% end_if %>
Is there any chance to use something like this instead:
<a href="$URL" rel="album" title="$Top.getAlbumTitle($Title)">$SetRatioSize(150,150)</a>
So far everything works fine, I just would like to have the image title (XX_my_image_title.jpg more clean ==> my image title).
If the template thingy doesn´t work, what else could I do?
9 December 2010 at 10:33am Last edited: 9 December 2010 10:39am
thanks to Arams great blog, I found the answer to my problem:
Just added a Decorator for the Image Class (as shown in Arams blog), which allows me to use this in my template:
<a href="$URL" rel="album" title="$getImageDescription">$SetRatioSize(150,150)</a>
Amazing, about 20 lines of code for a simple gallery, which creates thumbnails from all images located in a specified assets folder including a nice jQuery Colorbox animation for the full image size.
9 December 2010 at 4:33pm
Also FYI to anyone wondering
Won't work. You cannot as of 2.4 pass variables (ie $Foo) into the method or function. It has to be a static value e.g '2'.
9 December 2010 at 7:04pm
already expected something like this, as I haven't found any code around which uses this "technique"
So thanks for your answer, highly appreciated.
|Go to Top|