2
votes

I am using the extension News System, "news", and while changing the templates, I've noticed that while I can use things like {newsItem.datetime} or {newsItem.uid}, I cant use this with the custom fields i have created when extending the table tx_news_domain_model_news, like {newsItem.mycustomfield}

Edit: I have been pointed to this url and I've followed the instructions, but it's not working. This is my code

News.php

<?php
    class Tx_WedoExtendnews_Domain_Model_News extends Tx_News_Domain_Model_News {

        /**
        * @var string
        */
        protected $txWedoextendnewsLocation;

        public function getTxWedoextendnewsLocation() {
            return "this";
            return $this->txWedoextendnewsLocation;
        }
        public function getWedoextendnewsLocation() {
            return "that";
            return $this->txWedoextendnewsLocation;
        }
    }
?>

Since I wasn't getting anything, I changed the returning values to string literals, to see if the problem was in the class and method names, or the property. Im still not getting anything. I think the underscored might be playing tricks on my code.

My extension key is wedo_extendnews and the new field is tx_wedoextendnews_location. Any ideas where the error lies?

1

1 Answers

1
votes

Yes. To be able to access an object in fluid, you need the according setters in your model and maybe (not sure right now) an entry in the TCA.

If you want to access {newsItem.mycustomfield} you need an according setter in the model, like public function getMycustomfield() (note the get in get<Myfuncname>, it is mandatory).