Programmatically Adding Attributes to Page Types

Permalink
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.

MichaelG
 
mesuva replied on at Permalink Reply
mesuva
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
MichaelG
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
razorcommerce
This might helphttp://concrete5.ca/blog/c5-pagetype-default-programming/... for PageType Default programming andhttp://concrete5.ca/blog/concrete57-composer-programming/... for Composer Programming.
pilipala replied on at Permalink Reply
pilipala
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.

https://www.concrete5.org/community/forums/5-7-discussion/how-do-you...
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:http://concrete5.org/api/class-Concrete.Core.Page.Collection.Collec...

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
pilipala
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?