Custom news types

Out of the box news comes with three types built in:

  • "News": Default news record
  • "Internal Page": The news record is linked to a regular page.
  • "External Page": The news record is linked to an external URL.

To add your custom type, you have to follow the steps below.

1) Class Mapping

Create a file Configuration/Extbase/Persistence/Classes.php

<?php
return [
 \GeorgRinger\News\Domain\Model\News::class => [
     'subclasses' => [
         3 => \Vendor\ExtName\Domain\Model\MyCustomNewsType::class,
     ]
 ],
 \Vendor\ExtName\Domain\Model\MyCustomNewsType::class => [
     'tableName' => 'tx_news_domain_model_news',
     'recordType' => 3,
 ]
];
Copied!

2) TCA

In this example, the new type is configured to show the fields bodytext and title. Therefore, create the file Configuration/TCA/Overrides/tx_news_domain_model_news.php.

<?php
  defined('TYPO3') or die();

  $GLOBALS['TCA']['tx_news_domain_model_news']['columns']['type']['config']['items']['3'] =
    ['myCustomNewsType', 3] ;

  $GLOBALS['TCA']['tx_news_domain_model_news']['types']['3'] = [
    'showitem' => 'title, bodytext'
  ];
Copied!

3) Custom class

<?php

namespace Vendor\ExtName\Domain\Model;

class MyCustomNewsType extends \GeorgRinger\News\Domain\Model\News {

}
Copied!