TCA, Model and Fluid Partial to display FAL images as a simple gallery using TYPO3 and Extbase 6.1

revision b00293ba3130ca5f425bdc5071b6e83f1f10e7e0

raw

gistfile1.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
SQL:
images int(11) unsigned DEFAULT '0',
=======================================================
TCA
....
'images' => array(
        'exclude' => 0,
        'label' => 'images',
        'config' => \TYPO3\CMS\Core\Utility\ExtensionManagerUtility::getFileFieldTCA('images')
),
...
============================================================================
Model:
/**
 * images to use in the gallery
 *
 * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
 * @lazy
 */
protected $images;
 
/**
 * __construct
 *
 * @return AbstractObject
 */
public function __construct() {
        $this->images = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
}
 
/**
 * sets the Images
 *
 * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $images
 *
 * @return void
 */
public function setImages($images) {
        $this->images = $images;
}
 
/**
 * get the Images
 *
 * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
 */
public function getImages() {
        if ($this->images instanceof \TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingStorage) {
                $this->images->_loadRealInstance();
        }
        return $this->images;
}
==============================================================================
Fluid View (this is a Partial, providing all images with a link to open it in a lightbox, classic clickenlarge):
<f:for each="{images}" as="image" >
        <a href="{f:uri.image(src:image.uid,treatIdAsReference:1)}" class="lightbox" rel="gallery">
                <f:image src="{image.uid}" alt="" width='101' height="67" treatIdAsReference="1"/>
        </a >
</f:for >

History