Assetid Asset Attribute


(Nic Hubbard) #1

I am using the assetid asset attribute type, but I am wondering how I can use to to return information about the selected asset.


So, my user will be using an asset selector, which when an asset is chosen, I assume the ID is stored in that attribute. But, how can I return asset information about the asset that was selected?


(Huan Nguyen) #2

You can call

    $GLOBALS['SQ_SYSTEM']->am->getAsset($assetid)


and that would return the asset object, you can look at core/include/asset.inc or asset_manager.inc to see what information you can get out of the asset. What information do you want to extract?

(Nic Hubbard) #3

[quote]You can call

    $GLOBALS['SQ_SYSTEM']->am->getAsset($assetid)


and that would return the asset object, you can look at core/include/asset.inc or asset_manager.inc to see what information you can get out of the asset. What information do you want to extract?[/quote]

Thanks.

I think I can get it from there. :)

(Nic Hubbard) #4

Ok, I need a little more help. I am getting errors when trying to do it like this:

    $file = $GLOBALS['SQ_SYSTEM']->am->getAsset($this->attr('custom_attr'));


Is there something totally wrong with that way? I am wanting to use it to get the data path of the file asset that is chosen, so I was then going to use:

    $file_name = $file->data_path.'/'.$file->attr('name');


Error:

    Raw Entry:	[16-Feb-2009 20:54:26] PHP Fatal error: Uncaught exception 'Exception' with message 'Assertion failed: [NULL] "" is not a valid asset ID' in /Users/nnhubbard/Sites/mysource_matrix/core/include/assertions.inc:507

(Greg Sherwood) #5

$this->attr('custom_attr') must not be a valid asset ID. Check what is stored in there.


(Nic Hubbard) #6

It was my mistake, I figured it out. Thanks!