When writing the page_type template it’s possible to embed to areas using the standard area code,
$a = new Area('area_name'); $a->display($c);
Using the Defaults option on the Dashboard / Page Types screen it’s then possible to add blocks to the area you created. In my case I was installing the page_type as part of a package so I didn’t want to have to ask people using it to add in blocks themselves. After some help from someone on IRC I added the following code which allows me to add a content block to the area with some default content.
<br></br> $pagetype = CollectionType::getByHandle('page_type');<br></br> $mt = $pagetype->getMasterTemplate();<br></br> $bt = BlockType::getByHandle('content');<br></br> $mt->addBlock($bt, 'area_name',<br></br> array('btConfig' => '1',<br></br> 'content' => 'Default content'));<br></br>``` The trick turned out to be getting the master template for the page_type you have just installed and then adding the block to that using the standard addBlock() call. As I’ve just wasted a fair bit of time searching for a bug in my code that turned out to be a simple spelling mistake, make sure you have the same name for the area in the page_type template and in the above code 🙂