Create concrete5 page programatically

Submitted by remo - 6 years ago

Whether you want to create a custom script to import data from an old system, build a custom application, you'll probably have to create pages with code at some point in your concrete5 career.

// get home page
$homePage = Page::getByID(HOME_CID);

// get page type with handle "standard"
$collectionType = CollectionType::getByHandle('standard');

// build array with page information
$pageData = array();
$pageData['cName'] = 'Page Name';
$pageData['cDescription'] = 'Page Description';

// add new page underneath home page
$newPage = $homePage->add($collectionType, $pageData);

// set Meta Title attribute on new page
$newPage->setAttribute('meta_title', 'Meta Title for Page');
Stats Categories Tags
comments powered by Disqus