$page->getAttribute Get only the value, not object for building an array

So I'm having a little strategy and object/array/object access problem that I could use a suggestion on. Here is what I'm trying to accomplish.

Get all pages where a certain attribute has value. It's a select attribute, so I don't care what value it is, but I need to know if it has one or not. Then I need to make a menu of these pages, so I plan on building a navigation out of an array, but it needs to be ordered alphabetically, so I was going to dump the object values into an array, and do array_unique sorting on it. The problem is, $page->getAttribute('attribute_handle') grabs the object and not the value of the object, so array_unique doesn't work properly. I've tried accessing the object through normal means, but I'm not having much luck. Here is what the object / array / object looks like:

SelectAttributeTypeOptionList Object ( [options:Concrete5_Model_SelectAttributeTypeOptionList:private] => Array ( [0] => SelectAttributeTypeOption Object ( [error] => [ID] => 49 [value] => Mammography [th] => TextHelper Object ( ) [displayOrder] => 36 [usageCount] => ) ) [error] => )

If you echo this, you just get the value, but if you try and place it in to an array, you get the full object.

Here is my foreach loop:

function getSubmenu($pages) {
$departments = array();
foreach ($pages as $page) {
  $departments[] = $page->getAttribute('department');
return array_unique($departments);

Any suggestions would be appreciated! :)

View Replies:
JohntheFish replied on at Permalink Reply
That will be a particularly inefficient way of doing it.

Have a look at




It would probably be simpler if you use a page type rather than an attribute.

If you want that all in a page list without needing to write any code, my Uber List addon can do it.
afixia replied on at Permalink Reply
Ya we are taking over on a project from another company that has already put in all of the content and assigned attributes, so we gotta stay on this path. We just did find the solution to this though, thanks for your reply!
dwayneparton replied on at Permalink Reply
Could you post your solution?
dwayneparton replied on at Permalink Reply
Actually I found a solution. Thought I'd post just in case someone else was wondering.

$page->getAttribute('department', 'display');

Found it here: