Get and display page attribute name

Permalink 1 user found helpful
How would I get the NAME of an attribute, not just the value? I’d like to have something like:
Attribute Name1: Value1
Attribute Name2: Value2
…

in the page’s HTML without hard-coding the attribute name there.

 
10010110 replied on at Permalink Reply
Hello? Anybody there?
10010110 replied on at Permalink Reply
What’s up here? Isn’t there anybody of the core developers that could answer this question? I can’t imagine that this is so hard. I just am not enough of a PHP developer myself, otherwise I wouldn’t be asking here.
JohntheFish replied on at Permalink Reply
JohntheFish
IS this thread the same as your requirement?
http://www.concrete5.org/community/forums/customizing_c5/retrieving...
10010110 replied on at Permalink Reply
Well, that looks promising but I don’t want to list all attributes with keys and values, I just want to get a certain attribute by name/ID and output the name (key) and value dynamically (without a loop, if possible).

Something like:
Key <?php echo $cobj->getAttributeHandle('example'); ?>: Value <?php echo $cobj->getAttribute('example'); ?>

(this is just an example, I know that “getAttributeHandle” isn’t valid)

Surely, there must be a simple way to output the name of a certain attribute, not just its value?
JohntheFish replied on at Permalink Reply
JohntheFish
I have not used it, but from an attribute object getAttributeKeyName() may be what you are looking for.
guyDesign replied on at Permalink Reply
To get the name by handle:
CollectionAttributeKey::getByHandle('your_attr_handle')->getAttributeKeyName()