如何获取视图中相关对象的数据?CakePhP

如何获取视图中相关对象的数据?CakePhP,cakephp,Cakephp,我试图在我的视图中添加一个文本,但这似乎不起作用 在我的WepagesController.php中,我有一个用于aboutus.ctp的函数: public function aboutus() { // load the website base-layout $this -> layout = 'website'; // load relevant models $this -> loadMod

我试图在我的视图中添加一个文本,但这似乎不起作用

在我的WepagesController.php中,我有一个用于aboutus.ctp的函数:

        public function aboutus() {

        // load the website base-layout
        $this -> layout = 'website';

        // load relevant models
        $this -> loadModel('Contentitem');


    //query for 2 contentitems
    $aboutusinfos = $this->Contentitem->find('first', array('conditions' => array('contentitem_slug' => 'lorum')));
    debug($aboutusinfos);
    $aboutuspersons = $this->Contentitem->find('first', array('conditions' => array('contentitem_slug' => 'Robotics')));
    debug($aboutuspersons);
   //set the 2 contentitems     
    $this->set('aboutusinfos', $this->Contentitem->find('first', array('conditions' => array('contentitem_slug' => 'lorum'))));
    $this->set('aboutuspersons', $this->Contentitem->find('first', array('conditions' => array('contentitem_slug' => 'Robotics'))));


    }
这为我提供了正确的contentitems输出:

array(
    'Contentitem' => array(
        'contentitem_id' => '4',
        'contentitem_slug' => 'lorum',
        'contentitem_note' => ''
    ),
    'Contenttext' => array(
        (int) 0 => array(
            'contenttext_id' => '4',
            'contenttext_text' => '<p><span style="color: #555555; font-family: Verdana, Arial, sans-serif; font-size: 12.8px; text-align: justify;">A butt load of text</span></p>',
            'contenttext_rel_contentitem' => '4',
            'contenttext_rel_language' => '2'
        )
    )
)

array(
    'Contentitem' => array(
        'contentitem_id' => '3',
        'contentitem_slug' => 'Robotics',
        'contentitem_note' => ''
    ),
    'Contenttext' => array(
        (int) 0 => array(
            'contenttext_id' => '3',
            'contenttext_text' => '<p><span style="color: #555555; font-family: Verdana, Arial, sans-serif; font-size: 12.8px; text-align: justify;">A butt load of text</span></p>',
            'contenttext_rel_contentitem' => '3',
            'contenttext_rel_language' => '2'
        )
    )
)
数组(
“Contentitem”=>数组(
'contentitem_id'=>'4',
“contentitem_slug”=>“lorum”,
'contentitem_note'=>'
),
“Contenttext”=>数组(
(int)0=>数组(
'contenttext_id'=>'4',
“contenttext\u text'=>”一堆文本,
'contenttext\u rel\u contentitem'=>'4',
“contenttext\u rel\u language”=>“2”
)
)
)
排列(
“Contentitem”=>数组(
'contentitem_id'=>'3',
“contentitem_slug”=>“机器人技术”,
'contentitem_note'=>'
),
“Contenttext”=>数组(
(int)0=>数组(
'contenttext_id'=>'3',
“contenttext\u text'=>”一堆文本,
'contenttext\u rel\u contentitem'=>'3',
“contenttext\u rel\u language”=>“2”
)
)
)
我现在的问题是我不能像这样请求about.ctp中的contenttext\u text:

<div class="column_2">
<?php
echo $aboutusinfos['Contenttext']['contenttext_text'];

?>
</div>

只要我想访问
$aboutusinfos['Contentitem']
中的任何内容,它就会起作用,只是不想访问相关表。 有人有主意吗

echo $aboutusinfos['Contenttext'][0]['contenttext_text'];

你应该做这个把戏

先生,你是个英雄。