Forums / General / publish object with php

publish object with php

Author Message

Sebastian Sprenger

Wednesday 24 September 2003 5:45:55 am

Hi!
I try to publish an object in an extension (using php).
With
$object->setAttribute( "is_published", "1" );
$object->store();
I can set the object to 'IsPublished', but in the database (table ezcontentobject_tree) the object is still unpublished (contentobject_is_published = 0).
What can I do?

After the publishing an 'wait until date' event should start, but now even the publish doesn't work...

Thanks for your help,
Sebastian

Wenyue Yu

Wednesday 24 September 2003 6:38:20 am

Hi,

Try the following code:

include_once( 'lib/ezutils/classes/ezoperationhandler.php' );
$operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObjectID,
'version' => $contentObjectVersion ) );

wenyue

Sebastian Sprenger

Thursday 25 September 2003 1:14:21 am

Thanks, seems to work.
But I always have to run the command twice. First time nothing happens, no error.
After reloading the page the object is published.
Any idea why I have to run it twice??
Sebastian

Sergiy Pushchin

Thursday 25 September 2003 2:16:10 am

It seems like operation is halted by workflow and continued next time you run operation (when you reload). try to disconect workflow from publish trigger and see if it will be published from the first time.
--SP

Sebastian Sprenger

Thursday 25 September 2003 2:34:37 am

Sorry, even with no trigger connected the object isn't published from the first time.

Any more ideas? Thanks!

Sergiy Pushchin

Thursday 25 September 2003 4:19:01 am

Can you dump the $operationResult variable and show me the result? From the first and from the second run...

Sebastian Sprenger

Thursday 25 September 2003 4:38:22 am

$operationResult is: array(1) { ["status"]=> int(1) }
First and second time.