Tuesday 12 June 2012 12:08:27 pm
This snippet worked for me some years ago
$class will be the class you're trying to modify. As this was inside a class i build, $this->Language is used, but you can replace that harcoding it for the language you want.
$attributes = $class->fetchAttributes(); $new_attribute = eZContentClassAttribute::create( $class->attribute( 'id'), "ezstring", array(), $this->Language ); $attrcnt = count( $attributes ) + 1; $new_attribute->setName( "Valor", $this->Language ); $dataType = $new_attribute->dataType(); $dataType->initializeClassAttribute( $new_attribute ); $new_attribute->setAttribute( "version", 0 ); $new_attribute->setAttribute( "identifier", "valor" ); $new_attribute->setAttribute( "is_required", false ); $new_attribute->setAttribute( "placement", $attrcnt ); $new_attribute->store();
You must be logged in to post messages in this topic!