eZ Community » Forums » eZ Publish 5 Platform » Move content using public API?
expandshrink

Move content using public API?

Move content using public API?

Monday 17 June 2013 10:16:37 pm - 3 replies

Hi everybody!

I am trying to move a content object using the public APi, but I can't find how to do so.

I looked at the contentUpdateStruct but I do not see anything allowing me to change the content location. I can't just change the mainLocationId neither because it is read-only.

Is this even possible?

Thank you for any help.

Modified on Monday 17 June 2013 10:17:19 pm by Julien Montavit

Monday 17 June 2013 10:55:33 pm

Maybe de updateLocation() method?

Some code in https://github.com/ezsystems/ezpublish-kernel/blob/master/eZ/Publish/API/Repository/Tests/LocationServiceTest.php

Monday 17 June 2013 11:15:10 pm

Yes, 

you can using the Location service for moving the location of content below a other parent location.

$repository = $this->getRepository(); 
$locationService = $repository->getLocationService();
 
// Load a location and new parent location
$location = $locationService->loadLocation( [location_id] );
$newParentLocation = $locationService->loadLocation( [new_parent_location_id] ); 
 
$locationService->moveSubtree( Location $location, Location $newParentLocation );

If i can help you ?

Tuesday 18 June 2013 9:19:53 am

@David Suela :

I already looked at updateLocation method but you can only change a few location's attributes (but not the content inside the location, or I didn't find how)

@Franck Chaux:

Thank you. It works perfectly! Clear and simple.

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from