5329 Posts in 1599 Topics by 1169 members
|Go to End|
19 September 2013 at 9:58pm
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
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
27 September 2013 at 12:45am
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
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 , 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  which gets run when the user runs dev/build.
 http://api.silverstripe.org/2.4/source-class-DataObject.html#3015-3040 (example https://github.com/silverstripe/silverstripe-cms/blob/3.1/code/model/SiteTree.php#L1382)
|Go to Top|