Thursday, January 14, 2010

CakePHP Pagination Change Label

Here we can change the displayed label for CakePHP Pagination:

Say, we want to sort results by user_id.

This is how it is done by default:

<?php echo $paginator->sort('user_id');?>


And to change the displayed label:
 <?php echo $paginator->sort('User', 'user_id');?>

Here User is the label which will be displayed.
user_id is the field to be sorted.

4 comments:

Kim Pomares said...

Perfectly Simple. Cheers.

Unknown said...

but in cakephp2.x

sort('user_id', 'User');?>

Unknown said...

but in cakephp2.x

sort('user_id', 'User');?>

Eduardo Leoni said...

At least in the version i'm using (updated), you put the field first, and them, the label.

Regards