SlideShare una empresa de Scribd logo
1 de 19
Descargar para leer sin conexión
TCA Änderungen
in TYPO3 6.2
am Beispiel einer Erweiterung der News Extension
bisherige Situation
• Erweiterungen in ext_tables.php
• Kein Code Cache
• ext_tables.php wird zur Laufzeit mehrfach
eingelesen
• Unübersichtlich. Änderungen können sich leicht
gegenseitig überschreiben.
Configuration/TCA/Overrides
• Eingeführt mit TYPO3 6.2
• Beliebiger Dateiname
• Beliebig viele Dateien möglich
• Best practice:

<extkey>/Configuration/TCA/Overrides/
<tablename>.php
Vorteile
• klar definierte Stelle, wo Änderungen passieren
• TCA Änderungen landen im Code Cache
• ext_tables.php wird entschlackt
• Performance Gewinn im Backend wenn alle
Extensions das Feature nutzen
Beispiele
• Systemextensions
• css_styled_content
• saltedpasswords
• felogin
• news_exampleextension
News erweitern
Neue News Typen
und ein neues Feld
Struktur
• Extbase Verzeichnisstruktur
• Resources/Private/extend-
news.txt
• enthält Pfade zu den
Dateien, die erweitert
werden sollen
• Ohne Dateiendung .php
• Beispiel:

Domain/Model/News
Configuration/TCA/Overrides/

tx_news_domain_model_news.php<?php
defined('TYPO3_MODE') or die();
use TYPO3CMSCoreUtilityExtensionManagementUtility;
$tempColumns = Array (
'authorprofile' => Array (
'exclude' => 1,
'label' => 'LLL:EXT:news_exampleextension/Resources/Private/Language/
locallang_db.xlf:tx_newsexampleextension_domain_model_news.
authorprofile',
'config' => array(
'type' => 'group',
'internal_type' => 'db',
'allowed' => 'pages',
'foreign_table' => 'pages',
'size' => 1,
'minitems' => 0,
'maxitems' => 1,
'wizards' => array(
'suggest' => array(
'type' => 'suggest',
),
),
),
),
);
if (ExtensionManagementUtility::isLoaded('news')) {
// register new news types
$GLOBALS['TCA']['tx_news_domain_model_news']['types']['blogText'] =
$GLOBALS['TCA']['tx_news_domain_model_news']['types']['0'];
$GLOBALS['TCA']['tx_news_domain_model_news']['types']['blogImage'] =
$GLOBALS['TCA']['tx_news_domain_model_news']['types']['0'];
// add individual type icons
$GLOBALS['TCA']['tx_news_domain_model_news']['ctrl']['typeicons']['blogText'] =
ExtensionManagementUtility::extRelPath('news_exampleextension')
. 'Resources/Public/Icons/news_domain_model_news_blogText.png';
$GLOBALS['TCA']['tx_news_domain_model_news']['ctrl']['typeicons']['blogImage'] =
ExtensionManagementUtility::extRelPath('news_exampleextension')
. 'Resources/Public/Icons/news_domain_model_news_blogImage.png';
// add author profile only to above registered news types
ExtensionManagementUtility::addTCAcolumns(
'tx_news_domain_model_news',
$tempColumns
);
ExtensionManagementUtility::addToAllTCAtypes(
'tx_news_domain_model_news', 'authorprofile;;;;1-1-1', 'blogText,blogImage', 'after:related_from'
);
}
Configuration/TSconfig/Page/
mod.tx_news_domain_model_news.txt
TCEFORM.tx_news_domain_model_news.type.addItems {
blogText = LLL:EXT:news_exampleextension/Resources/Private/Language/
locallang_db.xlf:tx_newsexampleextension_domain_model_news.type.blogText
blogImage = LLL:EXT:news_exampleextension/Resources/Private/Language/
locallang_db.xlf:tx_newsexampleextension_domain_model_news.type.blogImage
}
ext_localconf.php
<?php
if (!defined ('TYPO3_MODE')) {
die ('Access denied.');
}
if (TYPO3CMSCoreUtilityExtensionManagementUtility::isLoaded('news')) {
// add page TSConfig which extends the news types
TYPO3CMSCoreUtilityExtensionManagementUtility::addPageTSConfig(
'<INCLUDE_TYPOSCRIPT: source="FILE:EXT:'
. $_EXTKEY .
‚/Configuration/TSconfig/Page/mod.tx_news_domain_model_news.txt">'
);
}
Classes/Domain/Model/AbstractNewsBlogItem.php
<?php
namespace KWSNewsExampleextensionDomainModel;
/**
* News model for default news
*
* @package TYPO3
* @subpackage tx_newsexampleextension
*/
abstract class AbstractNewsBlogItem extends Tx_News_Domain_Model_News {
/**
* @var integer
*/
protected $authorprofile;
/**
* Set author profile
*
* @param integer $authorprofile author profile
* @return void
*/
public function setAuthorprofile($authorprofile) {
$this->authorprofile = $authorprofile;
}
/**
* Get author profile
*
* @return integer
*/
public function getAuthorprofile() {
return $this->authorprofile;
}
}
Classes/Domain/Model/NewsBlogText.php
<?php
namespace KWSNewsExampleextensionDomainModel;
/**
* News model for default news
*
* @package TYPO3
* @subpackage tx_newsexampleextension
*/
class NewsBlogText extends AbstractNewsBlogItem {
}
Configuration/TypoScript/setup.txt
config.tx_extbase.persistence.classes {
Tx_News_Domain_Model_News {
subclasses {
blogText = KWSNewsExampleextensionDomainModelNewsBlogText
blogImage = KWSNewsExampleextensionDomainModelNewsBlogImage
}
}
KWSNewsExampleextensionDomainModelNewsBlogText {
mapping {
recordType = blogText
tableName = tx_news_domain_model_news
}
}
KWSNewsExampleextensionDomainModelNewsBlogImage {
mapping {
recordType = blogImage
tableName = tx_news_domain_model_news
}
}
}
Configuration/TCA/Overrides/

tt_content.php
<?php
if (!defined('TYPO3_MODE')) {
die ('Access denied.');
}
use TYPO3CMSCoreUtilityExtensionManagementUtility;
$_EXTKEY = $GLOBALS['_EXTKEY'] = 'news_exampleextension';
ExtensionManagementUtility::addStaticFile(
$_EXTKEY,
'Configuration/TypoScript',
'Additional types for EXT:news'
);
Fluid Template
• {newsItem.type}
• enthält neue Typen
• blogText
• blogImage
• {newsItem.authorprofile}
• enhält uid der Seite
Ressourcen
• https://forge.typo3.org/issues/57942
• http://ab-softlab.tumblr.com/post/90851249969/
tca-manipulation-in-typo3-6-2
• https://github.com/peterkraume/
news_exampleextension
Vielen Dank
@Cybersmog
peter.kraume@bgm-gmbh.de
http://de.slideshare.net/pk77
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Más contenido relacionado

Más de Peter Kraume

Más de Peter Kraume (10)

Get happy Editors with a suitable TYPO3 Backend Configuration
Get happy Editors with a suitable TYPO3 Backend ConfigurationGet happy Editors with a suitable TYPO3 Backend Configuration
Get happy Editors with a suitable TYPO3 Backend Configuration
 
TYPO3 best practice - showing a useful TYPO3 backend
TYPO3 best practice - showing a useful TYPO3 backendTYPO3 best practice - showing a useful TYPO3 backend
TYPO3 best practice - showing a useful TYPO3 backend
 
What’s new for TYPO3 Editors and in the TYPO3 World
What’s new for TYPO3 Editors and in the TYPO3 WorldWhat’s new for TYPO3 Editors and in the TYPO3 World
What’s new for TYPO3 Editors and in the TYPO3 World
 
Frontend Formulare in TYPO3 8 LTS
Frontend Formulare in TYPO3 8 LTSFrontend Formulare in TYPO3 8 LTS
Frontend Formulare in TYPO3 8 LTS
 
TYPO3 Monitoring mit t3monitoring
TYPO3 Monitoring mit t3monitoringTYPO3 Monitoring mit t3monitoring
TYPO3 Monitoring mit t3monitoring
 
Q&A Session zur TYPO3 Association
Q&A Session zur TYPO3 AssociationQ&A Session zur TYPO3 Association
Q&A Session zur TYPO3 Association
 
Composer und TYPO3
Composer und TYPO3Composer und TYPO3
Composer und TYPO3
 
TYPO3 Website Monitoring mit Caretaker
TYPO3 Website Monitoring mit CaretakerTYPO3 Website Monitoring mit Caretaker
TYPO3 Website Monitoring mit Caretaker
 
Caretaker TYPO3 Monitoring
Caretaker TYPO3 MonitoringCaretaker TYPO3 Monitoring
Caretaker TYPO3 Monitoring
 
Umfragen mit TYPO3
Umfragen mit TYPO3Umfragen mit TYPO3
Umfragen mit TYPO3
 

TCA Änderungen in TYPO3 6.2 am Beispiel einer Erweiterung der News Extension