Retrieving a list of all page attributes

I want to have a list of the attributes that are currently setup in the system, so that I can choose the attribute handle of one of them. I dont want the available choices in a particular attribute.

I have a block, and in my block I have to specify an attribute handle of a (select)attribute I want to choose/use in the block editing. I currently just have a text field, which I fill in the attribute handle, and that works fine. To make it more user friendly, I want to make a dropdown, populated with attribute handles I can choose from.

How would I go about doing something like this??
$aks = CollectionAttribute::getAllAttributes();
echo '<select>';
foreach( $aks AS $key ){
  echo "<option value=\"{$key->handle}\">{$key->name}</option>";
echo '</select>';

Any help would be much appreciated! Thanks, Andrew

View Replies:
adavis replied on at Permalink Reply
This actually works, to return a list of ALL attributes available.
$keyslist = AttributeKey::getList('Collection');
foreach($keyslist AS $key){
   echo "<p>{$key->akHandle}</p>";

I see that If I print_r the actual attribute objects, there is a pkgId value. If I could know what that pkgId is I could do something like this, which would return the attributes created in the package (more ideal situation!)

$pkg= Package::getById($the_id);
$keylist = AttributeKey::getListByPackage($pkg);

I dont see how I can know, from within the block controller, what package that block belongs to??
adavis replied on at Permalink Reply
I also dont see how I can know, from within the block controller, what block id it is.... Im so confused today =/
adavis replied on at Permalink Reply
I've settled on this for now. It does not give me kackage or block secific attributes, but in my application it could be possible to use ANY Select attribute to populate my block.

CONTROLLER in the edit() method:
$keyslist = AttributeKey::getList('Collection');
foreach($keyslist AS $key){
   if( $key->getAttributeType()->getAttributeTypeName() == 'Select' ){
      $available_aks["{$key->akHandle}"] = $key->akName;
$this->set('available_aks', $available_aks );

In the edit/add files:
<?php echo $form->label('category1AttributeHandle', 'Category 1 attribute handle');?>
<?php echo $form->select('category1AttributeHandle', $available_aks, $category1AttributeHandle );?>
<br/>(Handle of the attribute that will populate selector.)
Mireck78 replied on at Permalink Reply
//This is not working (C5 v5.6) - 'Collection' needs to be in lower case letters 
//This works
RadiantWeb replied on at Permalink Reply
Try this:

global $c;
$atts = $c->getSetCollectionAttributes();
foreach($atts as $at){
   echo $at->akHandle .' - '. $at->akID;
   echo '<br/>';

lucasschirm replied on at Permalink Reply
The easy way in the new version is just:

$attList = \Concrete\Core\Attribute\Key\CollectionKey::getList();
//you can