[TYPO3-english] Load Random Image from Directory into a Subpart
Christian Hennecke
christian.hennecke at wunderknaben.com
Fri Jun 21 09:28:48 CEST 2013
Am 21.06.2013 08:38, schrieb Scotty C:
Hi Scott,
> Hi everyone,
>
> I really thought this would be a simple task, but after hours of
> scouring the internet and running into plugins that just don't work,
> I find myself once again at the mercy of the group's wisdom. All I
> want to do is pop an image into a subpart, with the catch being that
> the image must be from a directory (not a content element) and pulled
> at random (as the directory has more than 1 image).
>
> At the most basic, we have: subparts.BANNER = IMAGE subparts.BANNER {
> file = fileadmin/demo/logo.jpg }
>
> ... but: - how do I load from a generic directory as opposed to
> specific image? I've seen file.import but can't find documentation
> (that I understand) on it. - as for random, I know it's listNum =
> rand, but again not sure what context to place it in.
Take a look at import.filelist. This should work together with
import.listNum. Something like this, although I haven't tried it myself:
10 = IMAGE
10.file.import {
filelist = fileadmin/images/|jpg,png,gif|ext|r|1
listNum = rand
}
filelist takes several parameters here:
fileadmin/images/: the path where to look for the files, of course
jpg,png,gif: return only files with these extensions
ext: sort the list by file extension
r: sort the list in reverse order
1: return the images with their path, not just the filename
filelist = fileadmin/images/|jpg,png,gif|name||1
Should be pretty much what you are looking for.
Cheers,
Christian
More information about the TYPO3-english
mailing list