Package attribute

Permalink 1 user found helpful
For a new theme I want to have a pagelist install with it which shows up thumbnails of pages, I have this all sorted but I have no idea how to install the 'thumbnail' attribute with my theme, I have looked at other packages but cant find any examples where this is done, this one you have to add it manuallyhttp://www.concrete5.org/marketplace/addons/thumbview-template/... but I dont want my purchasing clients to do this.

I know it is possible, I just dont know the syntax.

Thank you in advance

MattGreyDesign
 
PauloCarvalhoDesign replied on at Permalink Best Answer Reply
PauloCarvalhoDesign
Hi you can do this in your package controller:
Loader::model('collection_types');
$image_file = AttributeType::getByHandle('image_file'); //image attribute
$eaku = AttributeKeyCategory::getByHandle('collection');
         $eaku->setAllowAttributeSets(AttributeKeyCategory::ASET_ALLOW_SINGLE);
         $themeSet = $eaku->addSet('built_in',t('Custom Attributes'),$pkg);
CollectionAttributeKey::add($image_file,array('akHandle'=>'page_image','akName'=>t('Page Image(Thumbnai)'),'akIsSearchable'=>false),$pkg)->setAttributeSet($themeSet);
MattGreyDesign replied on at Permalink Reply
MattGreyDesign
Perfect, ill just copy that in then?
PauloCarvalhoDesign replied on at Permalink Reply
PauloCarvalhoDesign
add it to your install function.
You will notice i have created a attribute set.
If you find this correct please mark it as correct answer:)
Thank you!
MattGreyDesign replied on at Permalink Reply
MattGreyDesign
Hmm hasnt worked for some reason
PauloCarvalhoDesign replied on at Permalink Reply 1 Attachment
PauloCarvalhoDesign
can you tell me the error?

here is an example of the install function.
MattGreyDesign replied on at Permalink Reply
MattGreyDesign
It doesnt tell me much:

The following errors occurred when attempting to process your request:
1
PauloCarvalhoDesign replied on at Permalink Reply
PauloCarvalhoDesign
Try the example i sent you. Uses the same syntax the i use in pixel
pro theme available in the marketplace

On 4/15/11, Concrete5 Community <discussions@concretecms.com> wrote:
MattGreyDesign replied on at Permalink Reply
MattGreyDesign
You sent me an example? What do you mean?
PauloCarvalhoDesign replied on at Permalink Reply
PauloCarvalhoDesign
Yes i have upload a controller.zip look in my posts

On 4/15/11, Concrete5 Community <discussions@concretecms.com> wrote:
MattGreyDesign replied on at Permalink Reply
MattGreyDesign
Got it, sorry I'm not used to the attachments being there...
MattGreyDesign replied on at Permalink Reply 1 Attachment
MattGreyDesign
Take a look at my controller (attached), the example you gave me is a bit over my head :S sorry I'm still getting to grips with this.
PauloCarvalhoDesign replied on at Permalink Reply
PauloCarvalhoDesign
If you send me you package controller i will sort it out for you and
attach it back

On 4/15/11, Concrete5 Community <discussions@concretecms.com> wrote:
MattGreyDesign replied on at Permalink Reply
MattGreyDesign
Sorry wasnt around yesterday, yeah I attached it in the last message.
PauloCarvalhoDesign replied on at Permalink Reply 1 Attachment
PauloCarvalhoDesign
You where missing a model.
Plus I mage another comment on your controller regarding your page types.
Let me know how you get on!
MattGreyDesign replied on at Permalink Reply
MattGreyDesign
Ill have a try with this, Ill let you know in a bit.
MattGreyDesign replied on at Permalink Reply
MattGreyDesign
With the If statement (remember I'm a bit of a novice) It will have to be something along these lines, although I don't really have a clue where to wrap it around or anything :/ would you be able to give me any clue as I cant really find an example in any free themes?

$ct = CollectionType::getByHandle($ctHandle, $pkg);
     if(!$ct){
           $data['ctHandle'] = $ctHandle;
      $data['ctName'] = t($ctName);
      $data['ctIcon'] = $ctIcon;
      $ct = CollectionType::add($data,$pkg);
   }
     return $ct;


The controller you sent back still comes up with the same error :( cant figure it out.

Thanks