Share » Forums » Developer » New module extension

New module extension

New module extension

Wednesday 04 May 2011 2:28:28 pm - 7 replies

Modified on Wednesday 04 May 2011 2:39:26 pm by David Santiso

Author Message

Marko Žmak

Thursday 05 May 2011 12:28:42 am

For such a simple task as changing one attribute of an object, you don't need to extend the eZPersistentObject class. What you need is basically this:

  • get both object ID and attribute ID as a module parameter
  • fetch the object using the static fetch function of eZContentObject class
  • change the attribute and store it
  • sroe or publish the object

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

David Santiso

Thursday 05 May 2011 1:51:40 am

Ok, but if I call the store function I'll be making a new INSERT. I want to do an UPDATE.

Marko Žmak

Thursday 05 May 2011 2:20:41 am

Ok, but if I call the store function I'll be making a new INSERT. I want to do an UPDATE.

No it won't. The store method does an INSERT only if you create a new object of class eZContentObject. And since you will be fethcing an existing object it will do an UPDATE in your case.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

David Santiso

Thursday 05 May 2011 2:36:01 am

Ah!

Ok, thanks. I didn't understand it.

David Santiso

Thursday 05 May 2011 6:09:58 am

Ok. I've to do this in function.php:

includes...
 
$Module = $Params['Module'];

$objectId = $Params['ObjectId'];
$attributeId = $Params['AttributeId']; 
$version = $Params['Version'];
 
$contentObject= eZContentObject::fetchAttributesByIdentifier( $attributeId, $version, false, true );

... ?

But, how do I change the attribute?

Marko Žmak

Thursday 05 May 2011 6:32:27 am

You can find some usefull tips about it here:

  • http://share.ez.no/forums/developer/can-attribute-store-be-replaced-by-object-store
  • http://share.ez.no/forums/developer/how-to-edit-store-user-attributes-within-a-extension

The last comment in the first thread is the simplest, but I think it won't clear the cache.

As for the detailed docs about it I don't think there is any, you'll have to dig and try a little bit until you figure out what's the best for you.

--
Nothing is impossible. Not if you can imagine it!

Hubert Farnsworth

David Santiso

Thursday 05 May 2011 11:57:28 am

Thank you very much.

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu