Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

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

6,843 views

Published on

TCA Änderungen und Erweiterungen über Configuration/TCA/Overrides in TYPO3 6.2. Demo Extension "news_exampleextension" zur Erweiterung der News Extension von Georg Ringer

Published in: Internet
  • Be the first to comment

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

  1. 1. TCA Änderungen in TYPO3 6.2 am Beispiel einer Erweiterung der News Extension
  2. 2. 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.
  3. 3. Configuration/TCA/Overrides • Eingeführt mit TYPO3 6.2 • Beliebiger Dateiname • Beliebig viele Dateien möglich • Best practice:
 <extkey>/Configuration/TCA/Overrides/ <tablename>.php
  4. 4. 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
  5. 5. Beispiele • Systemextensions • css_styled_content • saltedpasswords • felogin • news_exampleextension
  6. 6. News erweitern
  7. 7. Neue News Typen und ein neues Feld
  8. 8. 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
  9. 9. 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', ), ), ), ), );
  10. 10. 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' ); }
  11. 11. 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 }
  12. 12. 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">' ); }
  13. 13. 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; } }
  14. 14. Classes/Domain/Model/NewsBlogText.php <?php namespace KWSNewsExampleextensionDomainModel; /** * News model for default news * * @package TYPO3 * @subpackage tx_newsexampleextension */ class NewsBlogText extends AbstractNewsBlogItem { }
  15. 15. 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 } } }
  16. 16. 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' );
  17. 17. Fluid Template • {newsItem.type} • enthält neue Typen • blogText • blogImage • {newsItem.authorprofile} • enhält uid der Seite
  18. 18. 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
  19. 19. 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.

×