I'm moving some of my content out of Umbraco and into a database. I want to keep the same URL structure that I currently have.
ie: /cycling/workouts/name-of-workout
I can do a url rewrite to get /cycling/workouts?workoutName=name-of-workout to /cycling/workouts/name-of-workout.
What I'm looking for is a function that converts "Name of Workout" to "name-of-workout". This is a simple case with just spaces and .toLower(), but I believe umbraco has a better internal function to do this. I'd also like to convert "name-of-workout" back to "Name of Workout" so I could query the database for the appropriate data.
Does anyone know if there's an API to do this switch or where the function is in the source?
Why would you want to move that out, seems like a function of a CMS to me. But umbraco.library.niceUrl is in charge of generating the url's you don't have any influence about the renderung process.
umbraco.cms.helpers.url.FormatUrl("Name of Workout")
This uses the urlReplacing section in umbracoSettings.config to replace all characters.
However I don't believe you can reverse it. What I tend to do is have a column for Name and a column for UrlName (using the funtion above) this allows me to query by either.
Thanks Sean, that's exactly what I was looking for.
The reason I'm moving my workouts out of Umbraco is that our site plans on letting users generate workouts. That means 1,000s of workouts being updated regularly. Plus I do some advanced sql queries on them to categorize/sort them.
Writing URLs like Umbraco
I'm moving some of my content out of Umbraco and into a database. I want to keep the same URL structure that I currently have.
ie: /cycling/workouts/name-of-workout
I can do a url rewrite to get /cycling/workouts?workoutName=name-of-workout to /cycling/workouts/name-of-workout.
What I'm looking for is a function that converts "Name of Workout" to "name-of-workout". This is a simple case with just spaces and .toLower(), but I believe umbraco has a better internal function to do this. I'd also like to convert "name-of-workout" back to "Name of Workout" so I could query the database for the appropriate data.
Does anyone know if there's an API to do this switch or where the function is in the source?
Thanks!
Why would you want to move that out, seems like a function of a CMS to me. But umbraco.library.niceUrl is in charge of generating the url's you don't have any influence about the renderung process.
not sure about inbuilt umbraco... but you could use ToTitleCase() from asp.net
Here is the native umbraco function that does it:
This uses the urlReplacing section in umbracoSettings.config to replace all characters.
However I don't believe you can reverse it. What I tend to do is have a column for Name and a column for UrlName (using the funtion above) this allows me to query by either.
Thanks Sean, that's exactly what I was looking for.
The reason I'm moving my workouts out of Umbraco is that our site plans on letting users generate workouts. That means 1,000s of workouts being updated regularly. Plus I do some advanced sql queries on them to categorize/sort them.
is working on a reply...