When you're trying to grab an attribute type value from outside the class it's best to discover the attribute type (by way of the key), then call the controller for that type, then call the methods that will get you that value.
I have to post the solution to this. I was tearing my hair out trying to find my way around the (quite powerful) attribute system when I stumbled on this in mnkras' docs:http://docs.mnkras.com/value_8php_source.html#l00083...
Apparently, if you pass a string value to the getValue() function of the AttributeValueObject, it will camelcase it and try to run the get{String}Value() function of your custom AttributeTypeController. I did have to rename my method to getCropValue(), but it worked like a charm. Here's a snippet that I used:
Loader::model('attribute/categories/file');// or /collection etc$ak= FileAttributeKey::getByHandle('my_attrib');// custom attrib with handle my_attribute$f=File::getByID(1)->getRecentVersion();// or however you are getting your file$avo=$f->getAttributeValueObject($ak);$data=$avo->getValue('awesome'));// this runs the MyAttribAttributeTypeController::getAwesomeValue() method
I hope someone else can use this thing; it was hairy trying to get down to it!
Code
Post Reply
Delete Post
You are allowed to delete your post for 5 minutes after it's posted.
Apparently, if you pass a string value to the getValue() function of the AttributeValueObject, it will camelcase it and try to run the get{String}Value() function of your custom AttributeTypeController. I did have to rename my method to getCropValue(), but it worked like a charm. Here's a snippet that I used:
I hope someone else can use this thing; it was hairy trying to get down to it!