[TYPO3-english] Random DAM image with TS problem
Christian Hennecke
christian.hennecke at ruhr-uni-bochum.de
Fri Jun 12 00:01:47 CEST 2009
Hello,
I need to select a random image from the DAM and obtain both image file
path and title for later use. This works by using a CONTENT object.
temp.randomImageFile = CONTENT
temp.randomImageFile {
table = tx_dam
select {
# Media folder id
pidInList = 46
# only use images
where = media_type = 2
# only use images from a certain directory
andWhere = file_path = 'fileadmin/images/'
orderBy = RAND()
max = 1
selectFields = title, file_name, file_path
}
renderObj = COA
renderObj {
10 = LOAD_REGISTER
10 {
randomImageDamTitle.data = field:title
}
20 = TEXT
20.field = file_path
20.wrap = |/
30 = TEXT
30.field = file_name
}
}
Now the problem is that I need the *same* randomly selected file several
times. When I use the above TS code for file.import.cObject, a *new*
file is selected every time:
10 = IMAGE
10 {
file.import.cObject < temp.randomImageFile
altText.data = register:randomImageDamTitle
}
20 = IMAGE
20 {
file.import.cObject < temp.randomImageFile
offset = 250,0
altText.data = register:randomImageDamTitle
}
Any idea how to do the selection only once? I guess I don't see the
forest for the trees here...
--
"I smell blood and an era of prominent madmen." - W.H. Auden
More information about the TYPO3-english
mailing list