Change page handle?

Permalink
Howdy!

Got what I hope is a simple question. I'm trying to set up a form that changes the name, and subsequently handle, of a page. Following the docs, I wrote this code (assume I've already validated that $handle is unique among all pages):

$handle = strtolower($name);
$handle = str_replace(array("\n","\t","\r"," ","-"),"_",$handle);
$projectPage = Page::getByID($project["page_id"]);

$update = array(
"cName" => $name,
"cHandle" => $handle
);
$projectPage->update($update);


This successfully changes the page name, but the handle remains unaffected - which leads me to believe I've either got the cHandle key wrong, or I've mistyped something. Any insight?

Thanks in advance!

 
CodeMoose replied on at Permalink Reply
So, I have more information that might be helpful.

For some reason, the page's $page->getCollectionHandle(); is returning the updated handle. The real problem seems to be that the page's canonical URL slug isn't updating with the new handle. This doesn't make sense to me - a quick peek at the source reveals that the canonical url's fieldname is cHandle, so it follows that the two would be one in the same.

Is the canonical URL a separate attribute that I can/should be updating, or is this a failsafe? perhaps even a bug?

Any insight is appreciated. Thanks!
CodeMoose replied on at Permalink Best Answer Reply
I found out yesterday that it was some sort of problem with my page. I changed the canonical url of a different page, then attempted the change via my form again, and it worked fine. Not sure what happened, but it doesn't seem to be reproducible now, so I won't worry about it.
pumppi replied on at Permalink Reply
Can u post your solution here. I have same kind of problem of updating the cHandle by form.


The Documentation and API naming is so stupid that Liferays API looks much better then Concrete5s. Liferays api is awful.
CodeMoose replied on at Permalink Reply
The only solution I've found is to go into the sitemap and change the page handle to match your cHandle - it sometimes takes a few tries too. I haven't tried it with 5.4.2 though so it might be better now. Let me know if you find a better solution.
pumppi replied on at Permalink Reply
Hi,

Hugh thanks for quick replay. I have tried it on 5.4.2 what was updated from 5.4.1. So no solution for this. It's looks like that is a bug. I will do an bug report for this.
mrowell replied on at Permalink Reply
mrowell
CodeMoose,

I think you need a $projectPage->rescanCollectionPath(); to the cHandle updated.

see http://www.concrete5.org/index.php?cID=366398...