Programatically updating a page path (cHandle) requires rescanCollectionPath()
Permalink 6 users found helpful
I found out after many hours of bashing away that to update a page path using $page->update() a rescanCollectionPath() is required.
I didn't see any mention of rescanCollectionPath() here in the forums. So I hope this post helps someone in the future.
Here is an example:
Also thanks to jshannon and digia3 on IRC for their help.
I didn't see any mention of rescanCollectionPath() here in the forums. So I hope this post helps someone in the future.
Here is an example:
$pagebycID = Page::getByID('113'); $new_data = array(); $new_data['cHandle'] = 'new-path'; $new_data['cName'] = 'new-title'; $pagebycID->update($new_data); $pagebycID->rescanCollectionPath();
Also thanks to jshannon and digia3 on IRC for their help.
![A3020](/files/avatars/136774.jpg)
Cool, I had the same problem. Thanks for sharing.
I guess we all have the same problemhttp://www.concrete5recipes.com/tricks/update-page-path-programmati... ;-)
Took me a minute to figure this out too..
Took me a minute to figure this out too..
That was driving me insane. Checked my code a few times, thought I'll see soon some pinky elephants flying by. You saved my day! Thanks!
Still a great POST even years later. Especially since the example of $some_page>add() with a "cHandle"=>"my_handle" does not use that handle as the page path (as documented).
I wasted more than a day trying to fix this problem.
THANK YOU!
I wasted more than a day trying to fix this problem.
THANK YOU!