Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS

Generate Webpages


4 Posts   370 Views


19 September 2013 at 9:58pm Community Member, 1 Post


I'm wondering if it's possible to mass generate webpages somehow.

I want to be able to generate a lot of empty webpages with the help of a script.

I am very new to this, can someone help me with a basic example of how this would be done?



20 September 2013 at 6:21pm Forum Moderator, 5511 Posts

You can generate pages on your site through PHP directly

$page = new Page();
$page->Title = "My Page";
$page->write(); // save the page

// publish it from draft to live
$page->doPublish('stage', 'live');


27 September 2013 at 12:45am Community Member, 1 Post

Sorry if I use this thread to ask, but where would I put that PHP code to be able to generate the pages and make them appear in the sitetree?



27 September 2013 at 8:36pm Forum Moderator, 5511 Posts

Well it depends on where and what context you want to generate the page. Are you running a database migration from an existing system and therefore should encapsulate the code into a BuildTask [1], or perhaps you need to create a page by default (say always create 1 homepage object) then you'd put that code in a requireDefaultRecords call [2] which gets run when the user runs dev/build.

[2] (example