function init() {
require_once ('embed.php');
$ret = GalleryEmbed::init(array('fullInit'=>true));
if ($ret) {
print 'GalleryEmbed::init failed, here is the error message: '.$ret->getAsHtml();
exit;
}
GalleryEmbed::done();
}
init();
$ret = GalleryCoreApi::deleteEntityById(45, 'GalleryItem');
if ($ret){
print 'GalleryCoreApi::deleteEntityById failed, here is the error message: '.$ret->getAsHtml();
exit;
}
return 'success'; // or TRUE
$ret = $item->delete();
if ($ret)
{
print 'GalleryCoreApi::deleteEntityById failed,
here is the error message: '.$ret->getAsHtml();
exit;
}
Please, Any suggestions?
suprsidr
Joined: 2005-04-17
Posts: 8339
Posted: Mon, 2010-03-22 12:09
Quote:
list ($ret, $item) = GalleryCoreApi::loadEntitiesById(37,'GalleryPhotoItem');
I assume 37 is the id of the photoItem you are trying to delete?
not the thumbnail, not the resize, not any derivative... the original photo
I ask because 37 is a very low number, it would have had to be one of the first items you added to your gallery.
and above you are trying to delete item 88
La imagen original es la id = 37, es un numero bajo porque es una gallery de prueba con una sola imagen.
gracias por contestar.
Sorry i did wrtite in spanish.
The original image is the id = 37, is a low number because it is a test gallery with a single image.
thanks for answering.
If i do:
$ret = GalleryCoreApi::deleteEntityById(37, 'GalleryPhotoItem');
and next:
list ($ret2, $item) = GalleryCoreApi::loadEntitiesById(37, 'GalleryPhotoItem');
I get the error:
GalleryCoreApi::loadEntitiesById failed, here is the error message: Error (ERROR_MISSING_OBJECT) : Missing object for 37.
Presumably the photo was deleted, but not eliminated Gallery2.
Gallery's Embed API allows for you to interact with gallery in most normal ways.
Including embedding gallery within your page(s) leaving gallery's MVC to manipulate the data. my site has gallery fully embedded allowing for user mapping between both applications.
You can also do a simple embed without user mapping.
Posts: 22
I'm trying whith this:
require_once("../gallery2/embed.php");
$ret = GalleryCoreApi::deleteEntityById(45, 'GalleryItem');
if ($ret)
{
return array($ret, null);
}
but nothing..
Thanks.
Posts: 8339
to use GalleryEmbed methods you must first init()
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 22
thanks for answering, but still no sign remove the photo
require_once("../gallery2/embed.php");
$ret = GalleryEmbed::init(array('fullInit' => true, 'g2Uri' => '/gallery2/main.php'));
$ret = GalleryCoreApi::deleteEntityById(45, 'GalleryItem');
if ($ret)
{
return $ret;
}
return null;
?>
Sorry but i'm very noob.
Thanks
Posts: 8339
$ret will be null if there is no error, so return/print success or true if you're expecting a response.
and I believe the correct EntityType is required now GalleryAlbumItem, GalleryPhotoItem, GalleryUser ...
http://gallery.menalto.com/apidoc/GalleryCore/Classes/GalleryCoreApi.html#methoddeleteEntityById
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 22
Thank you very much, now if you delete the photo
thanks
Posts: 22
Hello, I can not delete a picture, this code removes a full album.
Any suggestions?
thank you very much
Posts: 22
I use to remove a photo:
$ret = GalleryCoreApi::deleteEntityById(88,'GalleryPhotoItem');
but not detele photo
pls help me. thanks
Posts: 22
I've also tried ant nothigs:
list($ret, $user) = GalleryCoreApi::fetchUserByUsername("postgres");
$gallery->setActiveUser($user);
//get GalleryItem by itemId
list ($ret, $item) = GalleryCoreApi::loadEntitiesById(37,'GalleryPhotoItem');
print $item->getId() ;
print $item->getTitle();
print $item->getEntityType();
$item->releaseAllLocks( );
$ret = $item->delete();
if ($ret)
{
print 'GalleryCoreApi::deleteEntityById failed,
here is the error message: '.$ret->getAsHtml();
exit;
}
Please, Any suggestions?
Posts: 8339
I assume 37 is the id of the photoItem you are trying to delete?
not the thumbnail, not the resize, not any derivative... the original photo
I ask because 37 is a very low number, it would have had to be one of the first items you added to your gallery.
and above you are trying to delete item 88
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 22
La imagen original es la id = 37, es un numero bajo porque es una gallery de prueba con una sola imagen.
gracias por contestar.
Sorry i did wrtite in spanish.
The original image is the id = 37, is a low number because it is a test gallery with a single image.
thanks for answering.
If i do:
$ret = GalleryCoreApi::deleteEntityById(37, 'GalleryPhotoItem');
and next:
list ($ret2, $item) = GalleryCoreApi::loadEntitiesById(37, 'GalleryPhotoItem');
I get the error:
GalleryCoreApi::loadEntitiesById failed, here is the error message: Error (ERROR_MISSING_OBJECT) : Missing object for 37.
Presumably the photo was deleted, but not eliminated Gallery2.
Posts: 8339
Then the item was deleted.
try clearing the cache
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 22
nothing, I don't know to try
It should be easy to remove a photo...
Thanks for help me.
Posts: 8339
I've never tried removing a photo using the API, any reason you are not using the UI?
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 22
I need struct of gallery2 (data base) but no UI
Posts: 8339
Gallery's Embed API allows for you to interact with gallery in most normal ways.
Including embedding gallery within your page(s) leaving gallery's MVC to manipulate the data.
my site has gallery fully embedded allowing for user mapping between both applications.
You can also do a simple embed without user mapping.
There are also other ways to display gallery content outside of gallery:
http://www.flashyourweb.com/staticpages/index.php?page=mediaBlock
http://www.flashyourweb.com/staticpages/index.php?page=TheMiniSlideShow
http://www.flashyourweb.com/staticpages/index.php?page=TheExecutive
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 22
Thanks you very much suprdir,
solved, just put GalleryEmbed::done(), next the codec.
Thx for help me xxD.