Forum

Thread tagged as: Question

Routing and tokens for alphabetical pagination

Hi Guys,

Seem to be tripping up once again on routings and tokens. Sorry. I obviously don;t fully understand it (maybe a blog/video for it would aid me and others...anyway I digress...).

What I am trying to do is setup this alphabetical pagination. I have got so far with and I am able to filter out the right artists based on the letter. But what I am struggling with is displaying artist full pages or the pagination results.

So for example;
https://supershoes.loc/artists/a/ would show just artists who's first name begins with a. This works. But I have now broken this route; https://supershoes.loc/artists/amanda-j/ - which would show Amanda J's bio page.

How can I get this to work for both?

Any pointers?

Thanks, Terry

Terry Upton

Terry Upton 0 points

  • 5 years ago

It just clicked. The answer is adding a token of [i:page]
but is there a way to filter/limit it to just checking for one letter in the URL and then 404 if it is something else, at the moment, I am getting matches for bob, bill, bobbi, amanda, etc

Drew McLellan

Drew McLellan 2638 points
Perch Support

You need to create a custom routing token that matches just one letter. In your runway.php file:

'initial'       => '[a-z]{1}',

then in your route you can use

[initial:page]

thanks Drew. Thats it.