This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » Developer » Change siteaccess in eZ CLI PHP script

Change siteaccess in eZ CLI PHP script

Change siteaccess in eZ CLI PHP script

Monday 10 July 2006 11:03:40 am - 3 replies


I am using CLI scripts to import or update objects in EZPublish like explained in this post :

What I want to do is read an object in one site (one siteaccess, one db) and update the object in another
site (other siteaccess, other db). But I can't change the siteaccess within the script.

I use a script object and when I want to change the siteaccess, it does not work :

$script =& eZScript::instance(...);

I also tried with the method in EzPublish's index.php :

include_once( "access.php" );
$access = array('name'=> 'siteaccess1',"type"=> EZ_ACCESS_TYPE_HTTP_HOST);
$access = changeAccess( $access );
eZDebugSetting::writeDebug( 'kernel-siteaccess', $access, 'current siteaccess' );
$GLOBALS['eZCurrentAccess'] =& $access;

and I tried also with 2 eZScript instances :

$script2 =& eZScript::instance(...);

but always no success
my first question is : is it possible ?
if it is, does somebody did it and can help me ? if not, does somebody knows a workaround ?

Thanks for help

Monday 10 July 2006 11:17:34 am

Hello Fabio

Calling <i>$script->setUseSiteAccess('siteaccess1');</i> only works before <i>$script->initialize();</i>.

Have you tried the second method you mentioned with EZ_ACCESS_TYPE_STATIC instead of EZ_ACCESS_TYPE_HTTP_HOST?

Monday 10 July 2006 12:04:37 pm


I knew that and take care of calling $script->setUseSiteAccess('siteaccess1'); before $script->initialize();.
I tried every available access method from 1 to 8 (see access.php for details)

It seems that when siteaccess is selected, it can't be changed in the script ... ???

Friday 07 August 2015 2:44:10 pm

Works for me (v2015.01.3):

$access = array( 'name' => $siteaccess, 'type' => eZSiteAccess::TYPE_HTTP_HOST_URI );
eZSiteAccess::change( $access );

Version 4.3

$access = array( 'name' => $siteaccess, 'type' => EZ_ACCESS_TYPE_STATIC );
changeAccess( $access );

Modified on Friday 07 August 2015 3:07:43 pm by Alex Korshunov


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

36 542 Users on board!

Forums menu

Proudly Developed with from