paginate and sort 2nd level association
// link below
https://en.it1352.com/article/3565133a7e174035a4e83f831c59008d.html
// Our case:
MemberNotification -> BelongsTo -> Notification,
Notification -> HasMany -> NotificationLanguage
$this->MemberNotification->recursive = 0;
$this->set('memberNotifications', $this->paginate());
$this->MemberNotification->bindModel(array(
'belongsTo' => array(
'NotificationLanguage' => array(
'foreignKey' => false,
'conditions' => array('Notification.id = NotificationLanguage.notification_id')
),
)
));
// our purpose just make the NotificationLanguage same level with the Notification, show we can sort 2nd level association
// on the view
<th><?php echo $this->Paginator->sort('NotificationLanguage.title', 'Region'); ?></th>
// we cannot use below code, cannot run: xxxxxx
<th><?php echo $this->Paginator->sort('Notification.NotificationLanguage.title', 'Region'); ?></th>