Dave, having a little trouble following your post, but this is how you use the 
containable behavior:

$this->User->contain = array('Post.title', 'Post.description', 'Post.Bookmark');
$user = $this->User->findBySlug($slug);

If you're having trouble figuring out which models to contain, try:

$this->User->recursive = 2;
$user = $this->User->findBySlug($slug);
pr($user);

Then take a look at the output and you'll have a better idea of what to contain.

-Ryan



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 





-- 
View this message in context: 
http://n2.nabble.com/Data-from-multiple-Models-tp2578660p2578784.html
Sent from the CakePHP mailing list archive at Nabble.com.


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

Reply via email to