[TYPO3-english] Re: TCA configuration for sys_categories

Matt Clough matt at lubs.leeds.ac.uk
Wed Mar 2 17:43:45 CET 2016


I think I managed to figure out how to do this by using hook to do additional Post processing on the TCA.

This is called in the ext_localconf.php of an extensions:

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['extTablesInclusion-PostProcessing']['extensionname'] = 'vendorname\entensionname\Hooks\TcaCategories';

where vendorname and extensionname are your vendor name and extension name.

The Hook looks like the following:

<?php
namespace vendorname\entensionname\Hooks;

/*
 * This file is part of the TYPO3 CMS project.
 *
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
 *
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
 *
 * The TYPO3 project - inspiring people to share!
 */
use TYPO3\CMS\Core\Database\TableConfigurationPostProcessingHookInterface;


class TcaCategories implements TableConfigurationPostProcessingHookInterface {

	/**
	 * Function which may process data created / registered by extTables
	 * scripts (f.e. modifying TCA data of all extensions)
	 *
	 * @return void
	 */
	public function processData() {

		//	Categories for Pages
		$GLOBALS['TCA']['pages']['columns']['categories']['config']['foreign_table_where'] = ' AND sys_category.sys_language_uid IN (-1, 0) ORDER BY sys_category.title ASC';
	 	$GLOBALS['TCA']['pages']['columns']['categories']['config']['treeConfig']['appearance']['expandAll'] = 0;
	 	$GLOBALS['TCA']['pages']['columns']['categories']['config']['treeConfig']['appearance']['maxLevels'] = 1;
	 	
	 	//	Categpries for tt_content
		$GLOBALS['TCA']['tt_content']['columns']['categories']['config']['foreign_table_where'] = ' AND sys_category.sys_language_uid IN (-1, 0) ORDER BY sys_category.title ASC';
	 	$GLOBALS['TCA']['tt_content']['columns']['categories']['config']['treeConfig']['appearance']['expandAll'] = 0;
	 	$GLOBALS['TCA']['tt_content']['columns']['categories']['config']['treeConfig']['appearance']['maxLevels'] = 1;

	 	
	}

}

This will order the categories list alphabetically for both tt_content and pages. Once you collapse the list manually it will stay collapsed. 

Thanks

Matt




More information about the TYPO3-english mailing list