使用 1 个字段扩展 tx_news 没有 extension_builder [英] Extend tx_news with 1 field without extension_builder

查看:13
本文介绍了使用 1 个字段扩展 tx_news 没有 extension_builder的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用字段 imageright 扩展 tx_news 扩展.

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

为此,我找到了本教程:https://docs.typo3.org/typo3cms/extensions/news/2.2.1/Main/Tutorial/ExtendingNews/Index.html

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

第一步是使用extension_builder添加字段.因为我已经在我想实现扩展的地方有了一个扩展,所以我不想使用 extension_builder(我也用新的扩展尝试了它并扩展了新闻模型没有用 - 我不知道如何正确地做到这一点).但是,这是我所做的步骤:

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:

  • 在我的扩展 my_template 中,我添加了文件夹和文件:Classes/Domain/Model/News.php:

  • 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:

  • /Ressources/Private/extend-news.txt:

    Domain/Model/News
    

  • 在表tx_news_domain_model_news中创建字段imageright作为tinyint(并将其添加到SQL文件中)

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

    我知道我必须在 /Configuration/TCA/ 中创建一个 TCA 文件,但我不知道它应该是什么样子或它需要什么名称.我认为这是我需要使其工作的最后一步.

    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.

    还要注意扩展名 my_template 只是一个模板,所以在我更改之前,那里没有类和 TCA 文件.

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

    推荐答案

    解决方案是使用本教程:http://www.lukasjakob.com/extend-a-typo3-extbase-model-with-custom-field/

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

    这篇关于使用 1 个字段扩展 tx_news 没有 extension_builder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆