Problem Creating Pages Programmically in Concrete 5.8

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

Thank you for the assistance!

The chandle is definitely used to generate the initial path. What I’d do is:

  1. Add another page path to the page using $path = $page->addAdditionalPagePath()
  2. Loop over all the paths and set them to NOT canonical
  3. Set the new path to be canonical

Thanks Korvin. I just figured out the issue on my end… and this was one of those kick myself moments… If a concrete5 dev team member happens to read this, the issue was actually with the code I copy and pasted on this page: Working with Pages Programmatically

On that page the line reads:
'cHandle ’ => ‘hello-all’

There is an extra space after the “e” in handle that shouldn’t be there. I managedf to copy and paste it twice (first from the page, then from myself). Once that space was gone, all was good!

Thanks for the help! Hopefully someone who sees this can update the documentation.