Forums / Developer / Easier ways of getting an attribute from an object?

"Please Note:
  • At the specific request of Ibexa we are changing this projects name to "Exponential" or "Exponential (CMS)" effective as of August, 11th 2025.
  • This project is not associated with the original eZ Publish software or its original developer, eZ Systems or Ibexa".

Easier ways of getting an attribute from an object?

Author Message

Paul Forsyth

Wednesday 14 July 2004 4:25:41 am

I may have missed something but it would be very nice to have easier ways of getting attribute objects from objects without needing to search for yourself.

At the moment i either iterate through the array the function contentObjectAttributes returns from eZContentObject, or if i can safely use the index of the array i access directly.

eZContentObjectAttribute has the function fetchByIdentifier but that doesnt seem to get a specific identifier from a single attribute, which would be nice.

A function in eZContentObject to fetchByAttributeIdentifier would be nice.

paul

Paul Forsyth

Thursday 26 August 2004 7:03:46 am

Bumping this one up.

paul

Björn X

Thursday 26 August 2004 7:13:13 am

# co has one contentobject attribute called name(identifier)
$co = eZContentobejct::fetch($id);

$datamap =& $co->attribute('data_map');

$value = $datamap['name']->content();
or
$value = $datamap['name']->attribute('data_text');

$datamap['name']->setAttribute('data_text', ' new value');

$datamap['name']->store();

did this help?

Paul Forsyth

Thursday 26 August 2004 8:01:02 am

Excellent, thanks!

paul