add attribute (type select) from package

Permalink 1 user found helpful
Hi i'm looking to found how to add a select page attribute from package

for the boolean one i made like this in controller.php file:
      if( !$ExempleAttrKey || !intval($ExempleAttrKey->getAttributeKeyID()) )
      $ExempleAttrKey = CollectionAttributeKey::add('exemple', t('what this attribute doing'), false, null, 'BOOLEAN');

just to add a bolean choice, with no search and not activ by default.

But to add a select one with some values inside (no search and not by default) i didn't find anywhere how to set it.

is someone could help me ?


View Replies: View Best Answer
cali replied on at Permalink Best Answer Reply
got it since several, and never take time to share ... xcuse.

there is one way to install page attributes with your package:
explanation by example, not hard to understand.
//install my own attribute type select
// test if does not alreday exist
      if( !$MyOwnAttrKey || !intval($MyOwnAttrKey->getAttributeKeyID()) ) {
      $MyOwnAttrKey = CollectionAttributeKey::add('my_own_attribute_handle', t('My Attribute Name'), false, null, 'SELECT');
//fill the value inside the background attribute
      $MyOwnAttributeTypeOption = SelectAttributeTypeOption::add( $MyOwnAttrKey, 'one option', 0, 0);
      $MyOwnAttributeTypeOption = SelectAttributeTypeOption::add( $MyOwnAttrKey, 'annother option', 0, 0);
      $MyOwnAttributeTypeOption = SelectAttributeTypeOption::add( $MyOwnAttrKey, 'another again', 0, 0);
      $MyOwnAttributeTypeOption = SelectAttributeTypeOption::add( $MyOwnAttrKey, 'and so on', 0, 0);
      $MyOwnAttributeTypeOption = SelectAttributeTypeOption::add( $MyOwnAttrKey, 'my last option', 0, 0);
shahroq replied on at Permalink Reply
How should i create user attribute at install method of a package?
I want a boolean type.
shahroq replied on at Permalink Reply
I use this code to create a user attribute, it worked out:
$booleann = AttributeType::getByHandle('boolean');
UserAttributeKey::add($booleann, array(
                              'akHandle' => 'my_handle', 
                              'akName' => t('Attr Desc'), 
                              'akIsSearchable' => true,
                              'akCheckedByDefault' => true
milkmen replied on at Permalink Reply
I am hoping to get a better understanding of this, but I need to take a few steps back...

Let's say I want to add Page Attributes and Sets to a C5 install via Packages...

As far as I understand it, I would:

1) Copy "controller.php"? Which controller? Is it "root/concrete/controllers/page_types/core_stack.php"?

2) Add in my new attributes into that controller, then add it to "packages"? I assume that it needs to mime the same directory structure so that it knows where to put it?

If someone could point me in the right direction, that would be huge help. Thanks!
milkmen replied on at Permalink Reply
BTW: I know I can add this stuff in through the admin, I am just hoping to find a quicker, programmatic solution. Thanks.