Wednesday 04 January 2006 1:21:33 pm
I just figured out that I need to fetch the ezcontentattributes even though I might have a correct instance of a ezcontentobject.
$attrs = $target_object->contentObjectAttributes();
foreach( $attrs as $attr ) {
switch( $attr->contentClassAttributeIdentifier() ) {
case 'first_name': $first_name = $attr->attribute( 'data_text' );
break;
case 'last_name': $last_name = $attr->attribute( 'data_text' );
break;
case 'approved_by': $approved_by = $attr->attribute( 'data_text' );
break;
}
}
This is a really bothersome way to do it, and I wonder if there exist a easier way to automatically stuff the attributes in a much more simple (untyped) structure like an array with the contentClassAttributeIdentifier mapped against relevant value?
Something like this would be nice:
$doc = getDocumentById( $id ); echo "Document title: ".$doc->getAttribute("title"); No meta data unless I request it! :^)
|