[TYPO3-mvc] extending tx_news with own object
Eike Starkmann
starkmann at undkonsorten.com
Tue Jun 4 16:31:14 CEST 2013
Hi Johannes,
Am 04.06.2013 12:52, schrieb Johannes C. Schulz - EnzephaloN IT-Solutions:
> Hello extbase-friends
>
> Today I'm writing, cause my way of extending tx_news doesn't really work. In
> Backend it looks fine for now. But in frontend my assigned object will ot be
> displayed.
>
> In my extension I created a new model called News:
> namespace Enzephalon\Psoabilling\Domain\Model;
> class News extends Tx_News_Domain_Model_NewsDefault{
This should be class News extends \Tx_News_Domain_Model_NewsDefault{
Otherwise the Mapper would look at
Enzephalon\Psoabilling\Domain\Model\Tx_News_Domain_Model_NewsDefault
> /**
> * @var
> \TYPO3\CMS\Extbase\Persistence\Generic\ObjectStorage<\Enzephalon\Psoabilling
> \Domain\Model\Band>
> */
> protected $psoabilling;
> /**
> * The constructor.
> */
> public function __construct() {
> $this->psoabilling =
> $this->objectManager->get('Enzephalon\\Psoabilling\\Domain\\Model\\Band');
> }
> /**
> * @param \TYPO3\CMS\Extbase\Object\ObjectManagerInterface $psoabilling
> * @return void
> */
> public function
> setPsoabilling(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface
> $psoabilling){
> $this->psoabilling = $psoabilling;
> }
> /**
> * @return \TYPO3\CMS\Extbase\Object\ObjectManagerInterface $psoabilling
> */
> public function getPsoabilling(){
> return $this->psoabilling;
> }
> }
>
> The setup.txt has a mapping to assign News to Psoabilling:
> plugin.tx_news.persistence{
> classes {
> Tx_News_Domain_Model_News{
> subclasses{
> 0 = Tx_Psoabilling_Domain_Model_News
Shouldn’t it be Tx_Psoabilling_Domain_Model_News =
Tx_Psoabilling_Domain_Model_News
> }
> }
> Tx_Psoabilling_Domain_Model_News {
> mapping {
> tableName = tx_news_domain_model_news
> recordType = 0
And recordType = Tx_Psoabilling_Domain_Model_News, if you want to use
recordType.
> }
> }
> }
> }
>
Now you have a type of news called Tx_Psoabilling_Domain_Model_News
> Now I try to display my "psoabilling"-objects inside a news-item:
> <f:if condition="{newsItem.psoabilling}">
> <h2>Booking-News:</h2>
> <f:for each="{newsItem.psoabilling}" as="band">
> <img src="{band.logo}" />
> <ul>
> <li>Origin: <img src="{band.origin}" /></li>
> <li>Style: {band.style}</li>
> <li>Roots: {band.roots}</li>
> <f:if condition="{band.homepage}"><li><a href="{band.homepage}"
> target="_blank">{band.homepage}</a></li></f:if>
> <f:if condition="{band.myspace}"><li><a href="{band.myspace}"
> target="_blank">{band.myspace}</a></li></f:if>
> </ul>
> <span
> class="text"><f:format.html>{band.textde}</f:format.html></span>
> <img src="{band.photo}" />
> </f:for>
> </f:if>
>
> But sadly nothing is displayed. If I do a
> <f:debug>{newsItem.psoabilling}</f:debug> the output is NULL.
>
Is psoabilling there when you use <f:debug>{newsItem}</f:debug>?
> Can somebody tell me whats wrong with my model?
>
The problem could also be that the repository does not look for the
right type Tx_Psoabilling_Domain_Model_News.
Regards, Eike
>
>
> Thanks a lot
>
> Johannes
>
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
>
More information about the TYPO3-project-typo3v4mvc
mailing list