Jump to content

Title to URL function


Nico Knoll
 Share

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...