Jump to content

URL formatting


dps123
 Share

Recommended Posts

Hi @dps123. Welcome to ProcessWire and the forums.

page URLs are formatted using the $sanitizer->pageName('Title of Page') function. Have a read here.

Edit: Unless you are talking about the JavaScript that shows the live formatting as you enter the page title?

Edited by kongondo
Link to comment
Share on other sites

Thanks kongondo, I'll have a read. It's not the JavaScript live formatting, I just need to do it in PHP when I'm saving the page. Thanks again!

Edit: Actually, I remember trying this before. I'm getting this error:

Error: Call to a member function pageName() on a non-object

when doing this:

$pw_url = $sanitizer->pageName($name, true);

It's inside a custom function that I'm calling from my template.

Link to comment
Share on other sites

You are calling $sanitizer in the scope of a custom function. There you need to call it with wire("sanitizer")->pageName(), or, if you need it multiple times in your function: $sanitizer = wire("sanitizer"); and afterwards you can use $sanitizer->pageName().

This behaves the same with all PW template vars, like: $config, $pages, $templates, $sanitizer, $session, ...

  • Like 4
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...