Well, right now my index looks just like in the cookbook
<table>
<tr>
<th><?php echo $paginator->sort('Country', ''Country'); ?></th>
<th><?php echo $paginator->sort('Postal', 'Postal'); ?></th>
<th><?php echo $paginator->sort('Region', 'Region'); ?></th>
<th><?php echo $paginator->sort('City', 'City'); ?></th>
</tr>
<tr>
.....print the model entries
</tr>
</table>
When the user clicks "Country" the model view is ordered by country,
when he clicks "Postal" it's ordered by postal and so on....but he
can't order the whole view by "Country and Region" for example.
The $paginator is defined as follows:
var $paginate = array(
'fields' => array
('Myobject.id','Myobject.Name','Myobject.Country','Myobject.Postal','Myobject.Region','Myobject.City'),
'limit' => 100,
'order' => array(
''Myobject.Country' => 'desc',''Myobject.Postal' => 'asc'
)
);
On 26 Mai, 19:25, brian <[email protected]> wrote:
> OK, I understand. It looks like you'll need to check $this->params and
> deal with yourself some of the things paginator does automatically.
> The principle is the same, however: just add however many fields you
> need to the order array.
>
> It seems like you're going to make the interface overly complicated,
> though. But, without seeing your app, I can't really judge. Just an
> observation.
>
> On Tue, May 26, 2009 at 12:56 PM, Bs <[email protected]> wrote:
>
> > Hi,
>
> > thanks for the hint but I want to provide the users with buttons to
> > paginate the index view dynamically. Just like written in this howto
>
> >http://book.cakephp.org/view/166/Pagination-in-Views
>
> > but not only for singular columns but for 2, 3 or more so that they
> > can order their view after country, region and city for example. Right
> > now the code in my index view looks like this:
>
> > <th><?php echo $paginator->sort('Country', 'Country'); ?></th>
>
> > And what I would like to do is something like this:
>
> > $sort[] = "Country"; $sort[] = "Region"; $sort [] = "City";
> > <th><?php echo $paginator->sort($sort, 'Country'); ?></th>
>
> > So that the view is sorted by several keys when the user clicks.
>
> > On 26 Mai, 18:37, brian <[email protected]> wrote:
> >> On Tue, May 26, 2009 at 11:56 AM, Bs <[email protected]> wrote:
>
> >> > Hi,
>
> >> > I'm trying to order my index view by several conditions. As far as I
> >> > can see from the documentation, the $paginator only accepts one key
> >> > for sorting the model.
>
> >> >http://book.cakephp.org/view/166/Pagination-in-Views
>
> >> > What is the best practice to order my model by several keys? (For
> >> > example, ordering my cities by country, region, and city name in my
> >> > index view)
>
> >> 'order' => array(
> >> 'City.country' => 'ASC',
> >> 'City.region' => 'ASC',
> >> 'City.name' => 'ASC'
> >> )
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---