shida
shida

Reputation: 31

TYPO3 Extbase extend existing extension to use the model of own extension?

I'm trying to extend the extension (news) with three extra Date (timestamp) fields and want to call these in my fluidtemplate of (news).

I have wired up everything so far that i can see my extra fields in backend without selecting an extratype - i had modiefied ext_tables.php for that accordingly and can save the data.

Now i was trying to use these field in my news fluidtemplate using the following code in my Partials/List/Item.html - {newsItem.datetime}

I guess that i need to adapt with typoscript that the Model Tx_News_Domain_Model_News is now

config.tx_extbase{
    persistence{
        classes{
            Tx_News_Domain_Model_News {
                className = MyVendor\MyNews\Domain\Model\New
            }

            MyVendor\MyNews\Domain\Model\News {
                mapping {
                    tableName = tx_news_domain_model_news
                    recordType = Tx_MyNews_News
                }
            }
        }
    }    
}

But this seem not to work - anybody who got here a solution.

Upvotes: 3

Views: 2996

Answers (1)

lorenz
lorenz

Reputation: 4558

First of all, you don't necessarily need to extend EXT:news the "normal Extbase way". EXT:news offers a way to be extended with additional fields without overriding its model. It is documented here.

The advantage of this way is that multiple extension still can extend news without conflicting.

If you nevertheless want to do it "your way", you need to fix the configuration as follows:

plugin.tx_news {
  objects {
     Tx_News_Domain_Domain_News {
        className = My\Extension\Domain\Model\News
     }
  }
}

This tells Extbase to use your model class instead of the News model class.

config.tx_extbase.persistence.classes {
    Visol\Newscatinvite\Domain\Model\News {
        mapping {
            tableName = tx_news_domain_model_news
        }
    }
}

This tells Extbase to use the News table for your model.

Never forget to clear all system caches (class reflection is stored in the Database). You have a "Flush system caches" in the Backend if you are in Development context.

Upvotes: 3

Related Questions