Update page path programmatically

Submitted by remo - 7 years ago

A page has to be found somewhere and sometimes you might want to change that path, a part of the URL from within your code.

// get a page object, hard coded the page ID 131, replace with something you actually work with
$c = Page::getByID(131);

// specify the new path
$data = array(
    'cHandle' => 'new-path'

// update collection

// make sure the path table for the current page as well as its children are updated too.
// if you specify "true", concrete5 will retain the old path
Stats Categories Tags
comments powered by Disqus