Hi.

I have the following models: User, Membership, Group.
The Membership model is like a HABTM table, but contains some more
info, like the role of the user in the group.

I want to have an index page that lists all the groups of the logged
user.

Controller code
class GroupsController extends AppController
{
         ...
        function my_index()
        {
                $user_id = $this->Session->read('Auth.User.user_id');
                $this->paginate = array(
                        'conditions' => array('Membership.user_id' => $user_id),
                        'limit' => 25
                );
                $this->set('groups', $this->paginate('Membership'));
        }
}

View code
<table cellpadding="0" cellspacing="0">
<tr>
        <th><?php echo $paginator->sort('name');?></th>
        <th class="actions"><?php __('Actions');?></th>
</tr>
<?php foreach ($groups as $group): ?>
        <tr>
                <td>
                        <?php echo $group['Group']['name']; ?>
                </td>
                <td class="actions" style="width: 400px;">
                        ...
                </td>
        </tr>
<?php endforeach; ?>
</table>

The records are displayed fine. The problem is, when I click on the
table header to sort the results, nothing happens. It is always sorted
ASC. Also, there is no ORDER BY clause in the select query, in the sql
debug table.

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