Programmatically Adding Attributes to Page Types

Does anyone have examples of:

1. Programmatically adding attributes to Page Types (composer form)
2. Adding default content to a page template by page type

I started digging around, but juuuusttt a little confusing by just looking at it.

View Replies:
mesuva replied on at Permalink Reply
I'd also be really keen to see a basic example of 1., it's something I'm needing on a package I'm upgrading from 5.6 and haven't quite sussed out yet.
MichaelG replied on at Permalink Reply
Yeah, I got to adding a control set for the page type, but that's about as far as I got before getting lost. For me it ended up being easier to just build a dashboard page for the whole thing I'm doing and just create the pages from a form in there.
razorcommerce replied on at Permalink Reply
This might help for PageType Default programming and for Composer Programming.
pilipala replied on at Permalink Reply
Have you seen the thread below...not sure if the advice there is any help at all? In 5.6, page attributes could be added to page types in the controller.php file. This thread mentions that it is on the list for 5.7.3, but I'm not sure if it has been added yet.
goldhat replied on at Permalink Reply
I don't have the answer to this but I'm interested to find out. I will suggest that it looks to me from reading the API for 5.7 that the class for PageType has no use of attributes, whereas the Page/Collection has functions for attributes:

I haven't worked with C5 for awhile so I'm a little hazy on what a Collection is exactly but it would seem generally that attributes get attached to collections rather than page types. The mystery though is how does that relate to PageType Defaults and composer settings? I suspect it's something a bit tricky like you have to load the PageType default Collection, then attach attributes to it?
pilipala replied on at Permalink Reply
Interesting idea. I did assign my attributes to a collection, but only to make it clear to the user which attributes belonged to the package. For my project it wasn't really essential to add the attribute programatically to the page type, as I thought the user could just select the attribute from the attribute menu, or assign the attribute as a default. I wonder if it might be necessary to use sample content to assign the attributes to the page type in advance?