Skip to content

Instantly share code, notes, and snippets.

@fedir
Forked from maddy2101/gist:5668835
Last active December 19, 2015 22:48
Show Gist options
  • Save fedir/6029864 to your computer and use it in GitHub Desktop.
Save fedir/6029864 to your computer and use it in GitHub Desktop.
TCA, Model and Fluid Partial to display FAL images as a simple gallery using TYPO3 and Extbase 6.1

ext_tables.sql

images int(11) unsigned DEFAULT '0',

tca.php

TCA
....
'images' => array(
	'exclude' => 0,
	'label' => 'images',
	'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig('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() {
	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 >
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment