Welcome Guest, Not a member yet? Register   Sign In
friendly url's
#1

[eluser]Scott Boyde[/eluser]
I have a url that reads

/team/viewteam/1/1/2.html

each segment represents league/division/team, I wanted to replace the id values with the relevant names

I have been able to user str_replace and preg_replace so that I can have the team name displayed without the spaces.

so /team/viewteam/1/1/2.html becomes /team/viewteam/1/1/BarnUtd.html

What I would like to do now is only display /team/viewteam/BarnUtd.html

Is there any way that I can pass the 1/1 league/division into the controller as I need these to get the appropriate data from the DB tables.
#2

[eluser]Phil Sturgeon[/eluser]
Would recommend the use of slugs for this Scott. Not the type you find munching your lettuce, but good old url friendly identifiers.

On adding a team, use str replace to whittle their name down to something CI URL segment friendly and store it in the database. Then use that instead of an ID to call them.

Team names are relatively unique in all leagues right? If not, might be worth passing league slug too. Or /team/viewteam/BarnUtd-<leagueid>.html

Shove a route on it to get rid of viewteam and your URL is looking lovely.
#3

[eluser]Scott Boyde[/eluser]
Cheers, been able to get the url down to /team/viewteam/BarnUtd.html and works quite well. Should probably put in the route and replace the viewteam.




Theme © iAndrew 2016 - Forum software by © MyBB