Cakephp未定义属性错误

时间:2014-07-29 21:30:44

标签: php cakephp frameworks

我遇到了cakephp控制器的问题我一直收到错误

未定义的属性:AdsController :: $ getUrlsHTML

               public function getUrlsHTML($UrlId = 0) {
    // Called via AJAX to get HTML for CTAs
    // Provides insertable HTML based on list from getCalloutsActionsList()

    $this->layout = 'ajax';
    $UrlsList = $this->getUrlsActionsList($UrlId);

    $this->set('Urls', $UrlsList);
    $this->set('url', $UrlId);
    $this->render('/elements/ads/url');
}

private function getUrlsActionsList($UrlId = 0) {
    // Pulls appropriate Callouts list. Usually called by getCalloutsHTML()

    $Urls = $this->getUrlsHTML->getUrls();

    $UrlsList = array();
    foreach ($Urls as $Url) {
        $UrlsList[$Url['url']['id']] = $Url['url']['text']; 
    }

    return $UrlsList ;

}

2 个答案:

答案 0 :(得分:0)

您的控制器中是否声明了属性“getUrlsHTML”?我只能看到函数getUrlsHTML,所以你必须使用$ this-> getUrlsHTML()来调用它。

答案 1 :(得分:0)

$this->getUrlsHTML->getUrls();

无效。你想做什么?

错误确切地说明了你的问题是什么,getUrlsHTML不是属性,意思是“你为什么把它当作变量?”

$this->getUrlsHTML()

调用该函数,或

$this->getUrlsHTML()->getUrls();

如果你想连接。