1

I try to extend the tx_news extension with the field imageright.

For that I found this tutorial: https://docs.typo3.org/typo3cms/extensions/news/2.2.1/Main/Tutorial/ExtendingNews/Index.html

The first step is to use extension_builder to add the field. As I already have a extension in where I want to implement the extension I do not want to use the extension_builder (also I tried it with a new extension and extend the news-model did not work - I have no clue how to do it right). However this are the steps I did:

  • In my extension my_template I added the folders and file: Classes/Domain/Model/News.php:

        class MyTemplate_Domain_Model_News extends Tx_News_Domain_Model_News {
    
                /**
                * @var bool
                */
                protected $imageright;
    
    
                /**
                 * Returns the imageright
                 *
                 * @return bool $imageright
                 */
                public function getImageright() {
                        return $this->imageright;
                }
    
    
                /**
                 * Sets the sort
                 *
                 * @param bool $imageright
                 * @return void
                 */
                public function setImageright($imageright)
                {
                    $this->imageright = $imageright;
                }
    
        }
    
    ?>
    
  • /Ressources/Private/extend-news.txt:

    Domain/Model/News
    
  • Created the field imageright as tinyint in the table tx_news_domain_model_news (and added it to the SQL file)

  • I knew I have to create a TCA file in /Configuration/TCA/, but I have no clue how this should look like or what name it needs to have. I think this is the last step I need to make this working.

Also note the extension my_template was just a template, so before my changes there where no Classes and no TCA files.

nbar
  • 6,028
  • 2
  • 24
  • 65

1 Answers1

2

Solution is to use this tutorial: http://www.lukasjakob.com/extend-a-typo3-extbase-model-with-custom-field/

nbar
  • 6,028
  • 2
  • 24
  • 65
  • I have used this solution but the new field is not showing in frontend, debug newsItem , don't show it also, but i see it is the in the DB. Do you have an idea ? – Mohamed Masmoudi Apr 25 '21 at 20:16