Jump to content

Page name different when using API import


Soma
 Share

Recommended Posts

I have an import script that imports static html pages via API script. Some of the pages have a name like "001._pagename.htm".

Untill now it worked and the name of the page was the same and links worked to those documents.

Yesterday I did an update to latest PW, now it changes the name to "001-pagename.htm", and links stop working cause the name is different.

When and what did change? I think the previous core version was 2.1 or something. Can this be changed or avoided?

$p = new Page();
$p->parent = $parent;
$p->template = wire("templates")->get("gb-page");
$p->name = $filename; // sanitizes string different now
$p->title = $title;
$p->body = $dom;
$p->addStatus(Page::statusUnpublished);
$p->save();
Link to comment
Share on other sites

It sounds like the behavior you had before was with beautify turned off, and now it's turned on. Beautification includes removing adjacent punctuation characters, in addition to other things. You should be able to override that by setting it a second time (so that it knows you are serious). Try this:

$p->name = $filename; 
$p->name = $filename; 
  • Like 1
Link to comment
Share on other sites

Yeah I mean it serious!! :D

Hehe thanks a bunch Ryan, it actually works!

Funny solution I'd neve thought of myself. How comes it is like this? Is there something like outputformatting to turn beautifier off while creating pages?

Link to comment
Share on other sites

Output formatting always needs to be off when creating/saving pages. The beautification it does here is just the basic stuff that most of the time you don't want in URLs (like double dashes, adjacent punctuation, etc). Setting it twice is just an override for those rare cases when you really do want an unusual char combination.

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...