Creating a page type with custom attributes in page composer layout set in package controller.php

Permalink 1 user found helpful
Hi!

I want to create a package that on install adds three custom attributes, one page type and adds a composer layout set for the page type with the three custom attributes. I've managed to create the page type and the attributes, but I can't figure out how to create the composer layout form.

Does anyone have an idea?

I've seen and taken a lot of help fromhttps://www.concrete5.org/community/forums/5-7-discussion/installing...
and
https://github.com/core77/foundation_sites/blob/master/controller.ph...

Cheers

View Replies:
MrKDilkington replied on at Permalink Reply
MrKDilkington
I am interested in this topic also.
goldhat replied on at Permalink Reply
Great topic, found it searching for the same. Also wanting to create a package that installs a new PageType, then assigns Attributes and creates a composer layout. I've gotten started by using add() function from Concrete\Core\Page\Type\Typehttp://concrete5.org/api/source-class-Concrete.Core.Page.Type.Type....

That class handles adding the new PageType, and by setting the optional flag 'ptLaunchInComposer' the new PageType will open in composer. I'm going to search through the rest of the page type class to see if has functions for attaching attributes or composer settings.
mybudget replied on at Permalink Reply
The following works if you don't also need custom attributes:
// $pt = PageTypeType::add(...
      $set = $pt->addPageTypeComposerFormLayoutSet("Basics", "");
      $added = (new NameCorePageProperty())->addToPageTypeComposerFormLayoutSet($set);
      $added->updateFormLayoutSetControlRequired(true);
      $added->updateFormLayoutSetControlCustomLabel("Page Name");
      $added = (new DescriptionCorePageProperty())->addToPageTypeComposerFormLayoutSet($set);
      $added = (new UrlSlugCorePageProperty())->addToPageTypeComposerFormLayoutSet($set);
      $added = (new PublishTargetCorePageProperty())->addToPageTypeComposerFormLayoutSet($set);
      $added = (new PageTemplateCorePageProperty())->addToPageTypeComposerFormLayoutSet($set);
MrKDilkington replied on at Permalink Reply
MrKDilkington
Thanks mybudget.