How do I get the data of a related object to my view? CakePhP -


i'm trying text view doesn't seem work out.

in wepagescontroller.php have function aboutus.ctp:

        public function aboutus() {          // load website base-layout         $this -> layout = 'website';          // load relevant models         $this -> loadmodel('contentitem');       //query 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 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'))));       } 

this gives me correct contentitems output:

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'         )     ) ) 

my problem cant request contenttext_text in about.ctp this:

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

it work whenever want acess $aboutusinfos['contentitem'] not related table. have idea?

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

should trick


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -