Create Attribute Set on Package Install
Permalink
I have figured out how to create Attributes on Package install:
But, I am also trying to figure out how to create an Attribute Set on Package install... This functionality doesn't seem to exist (looking through the file 'concrete/core/models/attribute/set.php)
Am I not seeing something? Or is this just the way it is?
$attr = CollectionAttributeKey::getByHandle('exclude_subpages_from_nav'); if( !$attr || !intval($attr->getAttributeKeyID()) ) { $attr = CollectionAttributeKey::add('boolean',array('akHandle'=>'exclude_subpages_from_nav','akName'=>t('Exclude Subpages from Nav'),'akIsSearchable'=>false,'asID'=>2),$pkg); }
But, I am also trying to figure out how to create an Attribute Set on Package install... This functionality doesn't seem to exist (looking through the file 'concrete/core/models/attribute/set.php)
Am I not seeing something? Or is this just the way it is?
That's great, but how do you actually create the set?
You have $gallerySet referenced but you haven't created it. Is it possible programatically?
You have $gallerySet referenced but you haven't created it. Is it possible programatically?
//first create set: $eaku = AttributeKeyCategory::getByHandle('collection'); $eaku->setAllowAttributeSets(AttributeKeyCategory::ASET_ALLOW_SINGLE); $set = $eaku->addSet('my_set',t('My Set'),$pkg, 0); $asID = $set->asID; //now create attributes under the set: $key = CollectionAttributeKey::getByHandle('my_attr'); if (!$key || !intval($key->getAttributeKeyID())) { $attr_type = AttributeType::getByHandle('textarea'); $desc = array ( 'akHandle' => 'my_attr', 'akName'=> t('My Attribute'), 'asID' => $asID, 'akTextareaDisplayMode' => 'text' ); $key = CollectionAttributeKey::add( $attr_type, $desc , $pkg);
Viewing 15 lines of 16 lines. View entire code block.
I did have to make one modification, though.
I could not add the attribute set directly after creating the attribute as shown in the link. I had to create the attribute first and have it save as an object variable, and then add it to a set.