Nico Knoll Posted November 9, 2011 Share Posted November 9, 2011 Hi, how can I use the function PW is using to convert titles to URLs in e.g. a module? (Like this: "Hällö" -> "hallo") Greets, Nico Link to comment Share on other sites More sharing options...
Pete Posted November 9, 2011 Share Posted November 9, 2011 You'll need to use the $sanitizer, and in your case I think it would be: $url = $sanitizer->pageName($title, true); Obviously $title is whatever your title is. I'm not sure how it works with some characters, so let me know if that works for you. Full documentation on $sanitizer is here: http://processwire.com/api/variables/sanitizer/ Link to comment Share on other sites More sharing options...
Soma Posted November 9, 2011 Share Posted November 9, 2011 There's also setting that can be made in the InputfieldPageName module for converting chars, like ä to ae. Link to comment Share on other sites More sharing options...
Nico Knoll Posted November 9, 2011 Author Share Posted November 9, 2011 Hmm, I changed the setting like Soma said but it doesn't have any influence on "$sanitizer". Is there may a way to change it for $sanitizer? Link to comment Share on other sites More sharing options...
Soma Posted November 9, 2011 Share Posted November 9, 2011 Not sure. I thought it also gets when using sanitizer pageName. I think it should. Link to comment Share on other sites More sharing options...
ryan Posted November 9, 2011 Share Posted November 9, 2011 That setting for the InputfieldPageName module isn't used by $sanitizer. That is just used by the runtime javascript that performs conversions when you are entering characters in the page title (or directly in the page name) field. $sanitizer instead uses PHP's iconv() to perform conversions, and the translations it performs will depend on PHP's locale settings, or you can adjust them with PHP's setlocale() function. Such a thing (iconv) wasn't possible with just javascript (used by InputfieldPageName), which is why it's separate. Though with PW 2.2 and the multi language support, we will likely provide an option to have the $sanitizer->pageName() and InputfieldPageName pull from the same language-specific config data. Link to comment Share on other sites More sharing options...
Nico Knoll Posted November 9, 2011 Author Share Posted November 9, 2011 Well, I solved this with setlocale(LC_ALL, 'de_DE'); Thanks for your answers! Greets, Nico Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now