I would like to have a sorted-array (order by) to print out in my Post-
View.
The Problem is, that the order-by-attribute (Category.name) lies
deeper
than attributes (Post.id, Tag.id, ...), which have to be ordered.
Here is my example:
Relations:
Post --> hasMany --> Tag --> belongsTo --> Category
PostsController:
...
$posts = $this->Post->find('all', array (
'contain' => array (
'Tag' => array (
'Category' => array (
'fields' => array (
'id',
'name'
)
)
)
)
));
$this->set('posts', $posts);
...
Now i would like to to print out the posts-aray in my Post-View
to get this ordered table (order-by Category.name ASC):
Post.id Tag.id Category.name
---------------------------------------------------------------------
1 3 Basketball
1 2 Football
2 4 Hockey
4 1 Tennis
And my Question is:
Where do i have to put the "order"-clause to get this array, shown
above.
And if this will not work like this way, how will it work otherwise?
PS:
This is the "pr($posts);" which i want to have:
Array
(
[0] => Array
(
[Post] => Array
(
[id] => 1
)
[Tag] => Array
(
[0] => Array
(
[id] => 3
[Category] => Array
(
[id] => 1
[name] => Basketball
)
)
[1] => Array
(
[id] => 2
[Category] => Array
(
[id] => 5
[name] => Football
)
)
)
)
[1] => Array
(
[Post] => Array
(
[id] => 2
)
[Tag] => Array
(
[0] => Array
(
[id] => 4
[Category] => Array
(
[id] => 1
[name] => Hockey
)
)
)
)
[2] => Array
(
[Post] => Array
(
[id] => 4
)
[Tag] => Array
(
[0] => Array
(
[id] => 1
[Category] => Array
(
[id] => 1
[name] => Tennis
)
)
)
)
)
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