ExpressionEngine 7.5 has been Released! Learn More!
I’m using a segment variable to display a title on our website. However, in the URL the segment I’m pulling from sometimes has an underscore. Is there a way I can display the contents of {segment_2} with a space instead of an underscore?
e.g {segment_2} contains: “some_text” but I just want to display “some text” on the website.
You really only have the option for dashes -
or underscores _
when it comes to URL segments. You can set this using the word_separator
config variable, like $config['word_separator'] = 'dash';
That said, even if you COULD use spaces as a separator, there isn’t a single browser on the planet that would allow that, since a space isn’t a valid URL character; instead, every browser will convert every space to the encoded value of %20
. So a URL like /my/url title with spaces
would be converted to /my/url%20title%20with%20spaces
instead.
I’m sorry if that wasn’t clear. The URL has the underscore in it. I don’t want to create a new URL. I want to pull {segment_2} FROM the URL and display it on the website.
<html opening tag>{segment_2}</html closing tag>
But when I do that, I get something that looks like this:
My_Webpage_Title
But I want it to look like this:
My Webpage Title
Again, this has nothing to do with the url itself having spaces. That’s not what I’m going for.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.