getting the value of new file attribute called obj

Permalink 1 user found helpful
hi,I added a new attribute to the already existing file attributes called obj.Now I want to access the value of that obj.I can access the file name or title by fv->getTitle() , fv->getFilename() respectively but how will i get the vaue of new obj attribute

 
12345j replied on at Permalink Reply
12345j
try $fv->getPath();
sbpatil replied on at Permalink Reply
Hey Thanks for your reply but I am not quite sure,if I have understood it.The fv->getPath will give me the path isnt it? how will it help me retrieve the value with is store under the attribute obj for that file..Thanks in advance for your helo
12345j replied on at Permalink Reply
12345j
sorry, your question was a bit unclear to me, i thought you had gotten the page attribute.
$p=Page::getCurrentPage();
$p->getAttribute('attribute_name')->getVersion()->getPath()

this chained statement should work.
catslikeus replied on at Permalink Reply
Did you ever get an answer on this? You were looking for how to retrieve an file attribute value.

I am trying to do the same thing. I created a new file atrtribute and used it on a few photos. Now i want to get to those values.

I can get this from the file version

$fv->getAttribute('customer_name');


which returns this

SelectAttributeTypeOptionList Object
(
    [options:private] => Array
        (
            [0] => SelectAttributeTypeOption Object
                (
                    [error] => 
                    [ID] => 13
                    [value] => Melissa Kondrak Gocker
                    [th] => TextHelper Object
                        (
                        )
                    [displayOrder] => 1
                    [usageCount] => 
                )


Im trying to get to the VALUE of this selected option. How can I do this??

Any help much appreciated
catslikeus replied on at Permalink Reply
I guess what I need to know is what methods are available to call against SelectAttributeTypeOptionList. Any I have tried return an "method called on an non object" error, which is confusing since this looks like an object?
catslikeus replied on at Permalink Reply
Sadly the only way to figure this out was to dig thru the code itself. Fortunately its fairly clearly written...

This seemed to work. Once you have a file version object use this code to fetch the value of a select type file attribute on that file:

$attr = $fv->getAttribute('attribute_handle');
if( gettype($attr) == "object"){   //must make sure this is an object before we try and call methods
     $value = $attr->get('0')->getSelectAttributeOptionValue() ;
}
katiam replied on at Permalink Reply
catslikeus thank you so much, this is just what I needed.
I was storing some values in a session and all of a sudden my whole c5 site was broken, when I examined the session -one of the "values" I thought I had stored was indeed a select object, not a value- which seems to have been causing the trouble.
This code snippet helped heaps- Thanks!