Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Routing: replace hyphens with empty string in method/actions
  • Hi All, If I've got the following set up in my routing array:
    'admin/(:segment)' =>'admin/$1/index',
    'admin/(:segment)/view-all' =>'admin/$1/view-all',
    
    If my URL is /admin/case-studies/view-all, how do I set up my routing table to map this to /admin/casestudies/viewall without creating a special case each time a url has a hyphen in it? Sorry if I've not explained it well! Rob McCann :)
  • I have the same question and I'm very curious for the solution!
  • I don't have time to look into this right now, but basicly this is just a preg_match pattern that is parsed here: https://github.com/fuel/core/blob/master/classes/route.php#L156 As far as I see the whole Route class does nothing with hyphens, thus I can't think of anything right now. And as far as I can remember the replace pattern doesn't care about hyphens either, but you might try adding 2 backslashes before it..? (you need 2 to have one left after PHP parses the string which might then make preg_match handle the hyphen as just a character instead of removing it, if that is where it is removed) Btw if you're sure this is a bug or undocumented limitation: make it an issue on Github, we don't accept bugreports on the forums because that's not what the forums are for, that's what the issuetracker is for.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion