php - Concrete5 5.6.x - Setting Attribute Type Associations programmatically in a package controller -
i'm setting package concrete5 5.6.x adds bunch of user attributes on install. 1 of them uses image/file attribute comes concrete5. when install concrete5 not add image/file attribute type user attributes default (see screenshot below). when package goes add new attribute won't install because it's not available there. doesn't error out, nothing.
in dashboard can go in , check boxes make available:
it's not realistic tell people first before installing package. there must way programmatically can't find in forums or anywhere.
here's code controller function now:
private function addusersattr($pkg){ loader::model('user_attributes'); $img_att = attributetype::getbyhandle('image_file'); // set user $user_att_coll = attributekeycategory::getbyhandle('user'); if (!$user_att_coll->allowattributesets()) { $user_att_coll->setallowattributesets(attributekeycategory::aset_allow_single); } // user attribute set & attributes $user_att_set = attributeset::getbyhandle('author_info'); if(!is_object($user_att_set)){ $user_att_set = $user_att_coll->addset('author_info', t('author info'),$pkg); } $ai_portrait=collectionattributekey::getbyhandle('ui_portrait'); if( !is_object($ai_portrait) ) { collectionattributekey::add($img_att, array('akhandle' => 'ui_portrait', 'akname' => t('portrait image'), 'akissearchable' => false, 'uakprofileedit' => true, 'uakprofileeditrequired'=> false, 'uakregisteredit' => false, 'uakprofileeditrequired'=>false, 'displayorder'=> '9' ), $pkg)->setattributeset($user_att_set); } }
thanks
in controller using collectionattributekey in statement said trying add user attribute. if want add user attribute need use userattributekey.
Comments
Post a Comment