Concrete5.7.5.2 - How to get Topics tree attributes values into a select box?

Permalink
I have a Topics tree which I use as an attribute on a page:

Categories-
-Topic 1
-Topic 2
-Topic 3

How can I get the topics into an array in a block? Which I can then use in a select box? e.g.
$topics = ("Topic 1", "Topic 2", "Topic 3);
echo $form->select('categories', $topics);


And if my select box is on the right most side of the page, it always has the right border missing. If I move it anywhere else, it shows fine. Anyone else have this?

BTW, for those who want to get values from a select box attribute:
use Concrete\Core\Attribute\Key\CollectionKey as CollectionKey;
use Concrete\Attribute\Select\Controller as SelectController;
use Concrete\Core\Attribute\Type as AttributeType;
$ak = CollectionKey::getByHandle('region');
$at = AttributeType::getByHandle('select');
$satc = new SelectController($at);
$satc->setAttributeKey($ak);   
$values = $satc->getOptions()->getOptions();
foreach ($values as $key => $value) {
   $this->options[$value->getSelectAttributeOptionID()] = $value->getSelectAttributeOptionValue();
}

linuxoid
 
linuxoid replied on at Permalink Best Answer Reply
linuxoid
[SOLVED]
Thanks to Mike (http://stackoverflow.com/questions/33205693/concrete5-7-5-2-how-to-get-topics-tree-attributes-values-into-a-select-box), here's a piece of working code:
use Concrete\Core\Tree\Type\Topic as TopicTree;
public $category = array('');
public function view() {
...
    $this->requireAsset('core/topics');  
    $tt = new TopicTree();  
    $tree = $tt->getByName('My Categories');  
    $node = $tree->getRootTreeNodeObject();  
    $node->populateChildren();  
    if (is_object($node)) {  
        foreach($node->getChildNodes() as $key => $category) {  
            if ($category instanceof \Concrete\Core\Tree\Node\Type\Topic) {  
                $this->category[$category->getTreeNodeDisplayName()] = $category->getTreeNodeDisplayName();  
            }  
        }