Created
March 14, 2015 22:45
-
-
Save fnagel/96279d4e2ffb67825520 to your computer and use it in GitHub Desktop.
TYPO3 CMS 6.2 - Render a list of files by given folder path using TYPO3 core functionality (FILES cObject), extbase, fluid and a simple flexform plugin
This file contains 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
<?php | |
class ElementsController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController { | |
/** | |
* Renders folder download CE | |
* | |
* @return void | |
*/ | |
public function folderdownloadsAction() { | |
$this->view->assign('settings', $this->settings); | |
} | |
} | |
?> |
This file contains 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
<?php | |
if (!defined('TYPO3_MODE')) { | |
die ('Access denied.'); | |
} | |
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin( | |
'MyExtension.' . $_EXTKEY, | |
'ContentRenderer', | |
array( | |
'Elements' => 'folderdownloads', | |
), | |
array( | |
'Elements' => '' | |
) | |
); | |
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScript($_EXTKEY, 'setup', '[GLOBAL] | |
tt_content.' . $_EXTKEY . '_folderdownloads < tt_content.list.20.' . $_EXTKEY . '_contentrenderer | |
tt_content.' . $_EXTKEY . '_folderdownloads.switchableControllerActions.Elements.2 = folderdownloads', TRUE); | |
?> |
This file contains 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
<?php | |
if (!defined('TYPO3_MODE')) { | |
die('Access denied.'); | |
} | |
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin( | |
array('Folder Download', $_EXTKEY.'_folderdownloads'), | |
'CType' | |
); | |
$TCA['tt_content']['types'][$_EXTKEY.'_folderdownloads']['showitem'] = | |
'CType;;4;button;1-1-1, header, subheader, header_layout, pi_flexform, | |
--div--;LLL:EXT:cms/locallang_tca.xml:pages.tabs.access, starttime, endtime, fe_group'; | |
$TCA['tt_content']['columns']['pi_flexform']['config']['ds'][','.$_EXTKEY.'_folderdownloads'] = | |
'FILE:EXT:'.$_EXTKEY.'/Configuration/FlexForms/flexform.xml'; | |
?> |
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<T3DataStructure> | |
<sheets> | |
<sDEF> | |
<ROOT> | |
<TCEforms> | |
<sheetTitle>Settings</sheetTitle> | |
</TCEforms> | |
<type>array</type> | |
<el> | |
<settings.folders> | |
<TCEforms> | |
<label>Folder</label> | |
<config> | |
<type>group</type> | |
<internal_type>folder</internal_type> | |
<maxitems>1</maxitems> | |
<size>1</size> | |
</config> | |
</TCEforms> | |
</settings.folders> | |
</el> | |
</ROOT> | |
</sDEF> | |
</sheets> | |
</T3DataStructure> |
This file contains 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
<f:layout name="ElementLayout" /> | |
<f:section name="main"> | |
<f:cObject typoscriptObjectPath="lib.folderDownload" data="{settings}" /> | |
</f:section> |
This file contains 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
# Lib for rendering FILES cObject | |
# http://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Files/Index.html | |
lib.folderDownload = FILES | |
lib.folderDownload { | |
folders.field = folders | |
stdWrap.wrap = <ul class="download-list">|</ul> | |
renderObj = COA | |
renderObj { | |
wrap = <li>|</li> | |
stdWrap.typolink < tt_content.uploads.20.renderObj.10.stdWrap.typolink | |
stdWrap.typolink.ATagParams = class="download" title="{file:current:name}" | |
stdWrap.typolink.ATagParams.insertData = 1 | |
# filename | |
10 = TEXT | |
10 { | |
data = file:current:name | |
htmlSpecialChars = 1 | |
required = 1 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment