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:
in the page’s HTML without hard-coding the attribute name there.
Attribute Name1: Value1 Attribute Name2: Value2 …
in the page’s HTML without hard-coding the attribute name there.
Hello? Anybody there?
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.
IS this thread the same as your requirement?
http://www.concrete5.org/community/forums/customizing_c5/retrieving...
http://www.concrete5.org/community/forums/customizing_c5/retrieving...
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:
(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?
Something like:
(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?
I have not used it, but from an attribute object getAttributeKeyName() may be what you are looking for.
To get the name by handle:
CollectionAttributeKey::getByHandle('your_attr_handle')->getAttributeKeyName()
CollectionAttributeKey::getByHandle('your_attr_handle')->getAttributeKeyName()