Forums / Developer / Insert objects from module clear cache problem
H-Works Agency
Wednesday 08 February 2006 3:15:52 am
I have a module that insert content objects.
The problem : when cache is "on" i don't see the objects. I have to "clear content cache" to see the objects under the parent folder.
Why ? Is there a special command to clear cache inside my module's php code ?
How to clear cache in the modules php code, for a certain node ? What is the function syntax to do this ?
My object are inserted correctly, but i can't see them in admin unless i clear content cache.
Thanx
Martin
EZP is Great
Kristof Coomans
Saturday 11 February 2006 1:48:31 am
Hi Martin
This is the code you need:
include_once( 'kernel/classes/ezcontentcachemanager.php' ); eZContentCacheManager::clearContentCacheIfNeeded( $objectID );
Aren't you using the publish operation to insert those content objects? If you're using this operation, clearing caches would be done automatically. Or do these content objects already exist and are you creating additional node assignments?
independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org
Saturday 11 February 2006 8:24:25 am
Hi Kristof and thanx a lot for your code.
To respond to your question my extension is inserting objects inside one of my root folders, its not creating extra node assignements.
Actually i had hard time finding documentation about inserting an object from an extension, i had to browse contribution to take code as exemple but i didn't know if i used the right procedure but now that you say that the right EZP insert function is auto clearing the cache, i am shure i didn't use the right one because mine doesn't.
What is the "right" function to handle such operations ? I mean the built in ezp function that insert an object somewhere and clear parent's cache automatically ?
Thanx for everything,
Regards,Martin
Saturday 11 February 2006 9:51:45 am
After creating node assignments for your object, you should call the publish operation, as mentioned in this thread: http://ez.no/community/forum/general/publish_object_with_php:
$operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObjectID, 'version' => $contentObjectVersion ) );
There are other forum threads about programmatically creating content objects, like http://ez.no/community/forum/developer/importing_update_entry_if_it_already_exists, but they're quite hard to find with the search function.
Thursday 16 February 2006 8:00:58 am
I already use this function to insert my object from my module but it doesn't clear the cache...am i missing something ?
$operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObjectID, 'version' => 1));
Thursday 16 February 2006 8:26:21 am
Ok thanx a lot Kristian, in fact my function clear the cache by default, but it was missing this line :
include_once('kernel/classes/ezcontentcachemanager.php');