cake_1.2.x.x_6590

I'd been writing this cry for help when I suddenly had one more idea
to try ... and it works! Rather than delete this I thought it might
come in useful to someone else. And, if anyone cares to point out
something I've missed, or simply a better way to handle this, please
do let me know.

I have a view with a list of links, "a, b, c, ... " that are used to
place a find condition on last name. The controller is Artists but all
of the access to it is through custom routes because it's a
multilingual site. Some of my routes actually use regexp lists of
several words to match for a single controller but, in this case, it's
just a single word, 'repertoire', that the client really wants. So,
here are the index() routes:

Router::connect('/repertoire', array('controller' => 'artists',
'action' => 'index'));
Router::connect('/repertoire/index/*', array('controller' =>
'artists', 'action' => 'index'));
Router::connect('/repertoire/:letter/*',
        array('controller' => 'artists', 'action' => 'index'),
        array('letter' => '[a-z]{1}')
);

The 2nd route here was necessary to get pagination working with a
general find().

I'd originally had the 3rd route pointing to findByLetter() but
pagination wouldn't work with that and, as i'm just rendering the
index view anyway, i thought i'd try to send it to index() instead. If
'letter' is available in params that is used, otherwise, all artists
are fetched.

Unfortunately, the pagination links always look like, eg:

/repertoire/index/page:2

I wanted the helper to tell Router to write them like, eg:

/repertoire/b/page:2

I tried playing with $paginator->options['url'] but giving it a string
always result in that string being appended to '/repertoire/index'.
Passing an array with controller/action didn't make sense because I'm
using a custom route (and this is where the "Aha!" moment came).

What i did was place the following in my view:

if (isset($letter))
{
        $paginator->options['url'] = array('controller' => 'repertoire',
'action' => $letter);
}

Gadzooks! It works!

--~--~---------~--~----~------------~-------~--~----~
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