Hey All,
I’m having difficulty controlling the cHandle/seo path of a page. According to this page, Working with Pages Programmatically, setting cHandle is how you go about getting the seo_name/path variable set. There’s another forum post out there that also mentions needing to include a rescanCollectionPath(); to make it work. I’ve tried both setting it at time of creation, and after the fact, and I still end up with an automagically created cHandle based on the name. Can anyone point me to what I’m doing wrong before I go diving into source?
Here is my current sample code for reference:
$parentPage = \Page::getByPath('/locations');
$pageType = \PageType::getByHandle('page');
$template = \PageTemplate::getByHandle('locations');
$entry = $parentPage->add($pageType, array(
'cName' => $data['name'],
'cDescription' => $data['description'],
'cHandle ' => $data['seo_name']
), $template);
$entry->update(array('cHandle ' => $data['seo_name'])); //attempt 2
$entry->rescanCollectionPath();
Thank you for the assistance!