Archive

https://documentation.concretecms.org/tutorials/configure-composer-work-page-type

https://documentation.concretecms.org/building-website-concretecms/create-our-first-page-type/putting-it-all-together-create-the-page-type

https://documentation.concretecms.org/developers/working-with-blocks/creating-a-new-block-type/enabling-composer-editing-for-block-type

 
 

https://www.concrete5.nl/EN/videos/add-page/composer-output/

Unable to load block into composer.” when adding Page Programatically

$parent = Page::getByID(1);
$th = $app->make('helper/text');

$newPage = $pagetype->createDraft($template, $u = false);
 /* @var $newPage Page */
$newPage->setPageDraftTargetParentPageID( $parent->getCollectionID());
 $params = array(
         'cName' => $name,
          'cDescription' => $name,
           'cHandle' => $th->urlify($name)
 );
$newPage->update($params);
$saver = $pagetype->getPageTypeSaverObject();
$saver->saveForm($newPage);
$publishDateTime = false;
$pagetype->publish($newPage, $publishDateTime);

Thereafter, you would do something like this to update the block content:

$newarea = new Area('Main');
$newblocks = $newarea->getAreaBlocksArray($newPage);
foreach  ($newblocks as $newBlock){
       if ($newBlock->getBlockTypeHandle() === 'my_block_handle') {
              $clr = $newBlock->getController();
//Substitute whatever parameters the block needs:
              $clr->save(['title'=>$name, 'overview'=>$name, 'content'=>$content);
       }
}

Similar to the overwrite-mechanism for template, where you add a

templates directory to your block, you can add templates for the composer field.

This feature seems undocumented, but you can create following structure in your overwrite-block: overwrittenBlock\composer\myComposerTemplate.php

With that, a new option in the Composer Form Control appears in the select-list for design. So, a block for a view-template and a corresponding composer-template could look like:

file
   + templates
   └ pdfFile.php
   + composer
   └ pdfComposer.php