Hello All,

In response to the following post:

http://groups.google.com/group/cake-php/browse_thread/thread/c8ebc2097f8aad11/fae9ec58501534e6?lnk=gst&q=friend#fae9ec58501534e6

I have come up with my users having friends and admirers, thank you
gentlemen for that.

I am getting the array for both of them in my dump.

    [friend] => Array
        (
            [0] => Array
                (
                    [id] => 3
                    [username] => artist

                    [Friend] => Array
                        (
                            [id] => 1
                            [user_id] => 4
                            [friend_id] => 3
                            [approved] => 1
                        )

                )

            [1] => Array
                (
                    [id] => 5
                    [username] => testing

                    [Friend] => Array
                        (
                            [id] => 2
                            [user_id] => 4
                            [friend_id] => 5
                            [approved] => 1
                        )

                )

        )

    [admirer] => Array
        (
            [0] => Array
                (
                    [id] => 5
                    [username] => testing

                    [Friend] => Array
                        (
                            [id] => 3
                            [user_id] => 5
                            [friend_id] => 4
                            [approved] => 0

My question, and I think it is simple but I am still a newbie for the
most part -

How do I combine that data in the view to have both friends and
admirers as part of the same foreach statement?

Is that possible?  I have looked at Set::merge and tried that from the
controller.  Looked at custom query methods but the data is already
there in an array so I am a little stuck.

Here is what is in my view for the friends array and it is working
fine.  Just don't know how to get the admirer as part of it.

<?php foreach ($user['friend'] as $friend): ?>
<?php echo $friend['username'];?>
<?php echo $friend['created'];?>
<?php echo $this->Html->link(__('View', true), array('controller' =>
'friends', 'action' => 'view', $friend['id'])); ?>
<?php echo $this->Html->link(__('Delete', true), array('controller' =>
'friends', 'action' => 'delete', $friend['id']), null, sprintf(__('Are
you sure you want to delete # %s?', true), $friend['id'])); ?>
<?php endforeach; ?>

Thanks for any help!

Brad

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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