[TYPO3-english] Load Random Image from Directory into a Subpart

Scotty C superscotty19 at yahoo.com
Fri Jun 21 09:59:09 CEST 2013


Hey Christian,

Thanks for the speedy reply! Unfortunately, that didn't work. Specifically, I have:

page = PAGE 
page.typeNum = 0
page.19 = TEMPLATE 
page.19 { 
      template = FILE 
      template.file = fileadmin/demo/template.html       
      workOnSubpart = DOCUMENT 

      subparts.TOP_BANNER_AD = IMAGE
      subparts.TOP_BANNER_AD.import {
         filelist = fileadmin/images/|jpg,png,gif|ext|r|1
         listNum = rand
      }

}

I even tried playing with some of the examples here:
http://wiki.typo3.org/TypoScript_Header_Image

... to no avail.

Am I missing something?
-Scott.



________________________________
 From: Christian Hennecke <christian.hennecke at wunderknaben.com>
To: typo3-english at lists.typo3.org 
Sent: Friday, June 21, 2013 1:28:48 AM
Subject: Re: [TYPO3-english] Load Random Image from Directory into a Subpart
 

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
_______________________________________________
TYPO3-english mailing list
TYPO3-english at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english


More information about the TYPO3-english mailing list