Thursday, April 2, 2009

Data from multiple Models

I am trying to get info from 2 models displayed on a third controller. I think contain Post.title and Post.description but have no idea how to add that to the controller.
 
The user hasMany Bookmarks belongsTo Post hasMnay Bookmarks
 
I have users_controller to display the user/profile
 
user has the option to bookmark a post
the bookmark saves the user_id and the post_id so in the profile it shows Related Bookmarks straight from baked but all it shows is the ID , USER_ID and POST_ID naturally....
 
What i would like is the Bookmark to get the info from the post also so it shows the Post.title and Post.description
 
the view has the standard "foreach ($user['Bookmark'] as $bookmark): but what i cannot figure out is how do i get the Post info?
 
The profle function is stright from baked also:
 
function profile($slug = null)
      {
          $user = $this->User->findBySlug($slug);
          if (!$slug) {
              $this->Session->setFlash(__('Invalid User.', true));
              $this->redirect(array('action' => 'index'));
          }
          $this->set('user', $this->User->read(null, $slug));
      }
 
Thanks for any insight.
 
Dave

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: