-
-
Save overcome/2e8f86ec2d4a609b1d6b363eee03fb72 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SQL: | |
images int(11) unsigned DEFAULT '0', | |
======================================================= | |
TCA | |
.... | |
'images' => array( | |
'exclude' => 0, | |
'label' => 'images', | |
'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig( | |
'images', | |
array( | |
'appearance' => array( | |
'headerThumbnail' => array( | |
'width' => '100', | |
'height' => '100', | |
), | |
'createNewRelationLinkTitle' => 'LLL:EXT:your_extension/Resources/Private/Language/locallang_db.xlf:tx_yourextension_db_table.add-images' | |
), | |
// custom configuration for displaying fields in the overlay/reference table | |
// to use the imageoverlayPalette instead of the basicoverlayPalette | |
'foreign_types' => array( | |
'0' => array( | |
'showitem' => ' | |
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, | |
--palette--;;filePalette' | |
), | |
\TYPO3\CMS\Core\Resource\File::FILETYPE_TEXT => array( | |
'showitem' => ' | |
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, | |
--palette--;;filePalette' | |
), | |
\TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE => array( | |
'showitem' => ' | |
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, | |
--palette--;;filePalette' | |
), | |
\TYPO3\CMS\Core\Resource\File::FILETYPE_AUDIO => array( | |
'showitem' => ' | |
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, | |
--palette--;;filePalette' | |
), | |
\TYPO3\CMS\Core\Resource\File::FILETYPE_VIDEO => array( | |
'showitem' => ' | |
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, | |
--palette--;;filePalette' | |
), | |
\TYPO3\CMS\Core\Resource\File::FILETYPE_APPLICATION => array( | |
'showitem' => ' | |
--palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, | |
--palette--;;filePalette' | |
) | |
), | |
), | |
$GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] | |
) | |
), | |
... | |
============================================================================ | |
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="{image.originalResorce.alternative}" 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