Hi,

If I understand correctly, you just need to sort on two fields, right?

Here's some code of a controller of mine that sorts a paginated table
of texts (lyrics). Texts belong to Albums which belong to Artists. The
table can be sorted on title, artist or year. As you can see in each
case I use the $order array to sort on multiple fields...


 function index($sort = 'title') {
    if ($sort == 'artist')
      $order = array(
        'Artist.sort' => 'desc',
        'Artist.name' => 'asc',
        'Text.title' => 'asc',
        'Text.year' => 'asc'
      );
    elseif ($sort == 'year')
      $order = array(
        'Album.year' => 'asc',
        'Artist.sort' => 'desc',
        'Artist.name' => 'asc',
        'Text.title' => 'asc'
      );
    else  // title
      $order = array(
        'Text.title' => 'asc',
        'Text.year' => 'asc',
        'Artist.sort' => 'desc',
        'Artist.name' => 'asc'
      );
    $this->paginate = array(
      'conditions' => "",
      'limit' => 50,
      'order' => $order
    );
    $this->Text->recursive = 0;
    $this->set('texts', $this->paginate());
  }


Later I had to abandon Cake's pagination and make my own because I
wanted to be able to take the year from either the Text or the Album
when sorting on it.

Anyway you'll need something like this:

 if ($sort == 'citystate')
      $order = array(
        'Skatepark.state' => 'asc',
        'Skatepark.city' => 'asc'
      );
...



On May 3, 12:05 pm, Kyle Decot <[EMAIL PROTECTED]> wrote:
> I have a skatepark directory website and I want to be able to sort my
> results by park name, rating, and city/state. I am having some
> problems figuring out how to do the city/state sort with paginate. I
> want to sort the states, and then sort the cities within the states.
> Anyone have any tips on how to accomplish this? Thanks for the help.
--~--~---------~--~----~------------~-------~--~----~
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