Multiple siteaccess for one site = Groups of settings ?

Author Message

H-Works Agency

Tuesday 29 November 2005 4:59:39 pm

Is it possible to have multiple settings/siteaccess/ for one site ?

For example www.siteA.com/admin would check for settings in

- /settings/siteaccess/siteA
- /settings/siteaccess/site_Common

This could correspond to a setting like this in site.ini :

HostMatchMapItems[]=siteA.com;siteA|site_Common

But for the moment only one 'siteaccess' looks possible. Thus some settings are repeated through some settings/siteaccess/ and i can't put them in settings/override/ because those directives are not shared by all my sites.

<b>It would allow users to have .ini settings for groups of sites.</b>

For example all my web-sites have common override.ini settings, but they are not common with my admin-sites.

How can i do this ? Is this the good approach ?

If it's not possible will it be in a near future ?

Thanx for the always professional help i get on this forum.

Martin

EZP is Great

H-Works Agency

Friday 09 December 2005 3:34:11 am

Can anyone close to the ezp dev team can give me a few clue about this point ?

EZP is Great

André R.

Thursday 29 December 2005 2:13:05 pm

Why don't you have multiple ez installs instead, one for each group of pages.
They can still share the same database..

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Esteban Rodriguez

Saturday 31 December 2005 5:56:29 am

Hi Martin,

I don't think you can do that yet.
Since eZ reads ini files in the following order:
settings dir
siteaccess dir
override dir

What we usually do on multisite installations is have all our "standard" settings modifying the original ini files in the settings dir (which we actually shouldn't do). This gives us our standard setup.
Then we just need to add the options that change from site to site in the siteaccess dir, this makes for much smaller .ini.append files.
We just use site.ini.append in the override dir to set the HostMatchMapItems[] array and the extensions.

I don't know if this is the best approach, but it works for us.

I have great faith in fools; self-confidence my friends call it.

http://presencia.net

H-Works Agency

Saturday 31 December 2005 6:22:42 am

Thanks for your contribution.

Its true i could modify the /settings/*.ini files to get a siteaccess shared configuration but i upgrade EZP all the time so my configuration/design politics rely on not modifying installation files...

So i prefer for the moment repeating those common settings in each siteaccess though my ezp install support 20 websites...

Being able to share multiple siteaccess for one site would definitly be a good feature to add to avoid repeating standard parameters accross siteaccesses without modifying install base files.

Martin

EZP is Great

Thomas Nunninger

Saturday 31 December 2005 7:37:10 am

Hi Martin,

I had the same problem some month ago. I wanted to create a multi language site. All settings were the same - only the locales changed. So I patched eZ to work with what I called "hierarchical siteaccess". It works a little bit in another way like your suggestion. The idea is:

Your siteaccess (settings folder) is something like this:

settings/
  siteaccess/
    project_1/
      admin/
      public/
        ger/
        eng/
          uk/
          us/
    project_2/
      ...

Now you can define things like database in the directory project_1/. Admin things go in project_1/admin/. General public siteacces go into project_1/public/. And local settings for the public domains are set in the ger/ or eng/uk/, ... folders. (Of course you are not limited to localization settings.)

If there is a request and your siteaccess is project_1/public/eng/uk eZ will read all settings in project_1/, project_1/public/, project_1/public/eng/ and project_1/public/eng/uk. If there are the same settings in more than one of those directories the most specific is chosen. (The least specific is project_1/ and the most specific uk/ in this case).

The override/ settings behave like known - they are global musts.

The patch is lying around somewhere. And there have been minor issues. I will try to check it till Monday or Tuesday. Stay tuned :-)

I wish you all a happy new year

Thomas

Thomas Nunninger

Tuesday 03 January 2006 2:06:46 pm

Hi Martin,

sorry, I wasn't able to finish my announced patch, because I had some issues with my Linux-Installation :( I hope I can post it tomorrow.

By the way: which MatchOrder do you have in site.ini? Host? URI? At the moment my patch only works with Host setting. If you have another setup, I need to look into the code a little deeper again.

Thomas

Kristian Hole

Wednesday 04 January 2006 12:19:03 am

I don't think you can do that yet.
Since eZ reads ini files in the following order:
settings dir
siteaccess dir
override dir

There is also extensions here, so the correct order is
settings dir
siteaccess dir
extensions dir
override dir

This means you can use common settings in an extension, and have groups of siteaccesses using different extensions.

Kristian

http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute

Thomas Nunninger

Wednesday 04 January 2006 3:07:47 am

Hi Kristian,

are you sure, this is the right order?

settings dir
siteaccess dir
extensions dir
override dir

In access.php I find this code:

function changeAccess( $access )
{
    ...
    if ( file_exists( "settings/siteaccess/$name" ) )
    {
        $ini->prependOverrideDir( "siteaccess/$name", false, 'siteaccess' );
    }

    /* Make sure extension siteaccesses are prepended */
    include_once( 'lib/ezutils/classes/ezextension.php' );
    eZExtension::prependExtensionSiteAccesses( $name );
    ....
}

My idea was mainly to patch eZini::prependOverrideDir() so that all the directories in the siteaccess path (e.g. project/public/ger) will be looked for setting files.

Btw.: the idea with the extension settings seems to be a much smarter solution at the given code :-)

Have a nice day

Thomas

Kristian Hole

Wednesday 04 January 2006 4:03:57 am

@Thomas:

are you sure, this is the right order?

Yes, that is atleast the way i'm using it ;-).

Kristian

http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute

H-Works Agency

Wednesday 04 January 2006 4:19:50 am

Using the 'extension' dir to stock grouped settings looks like a great idea as it respect my politic of not modifying ez sources !!! Well done Kristian.

So i would put my grouped settings under :

For admin sites : $ezp/extensions/common_admin_settings/settings/.ini
For public sites : $ezp/extensions/common_sites_settings/settings/.ini

Then in each site's site.ini i would use :

[ExtensionSettings]
ActiveAccessExtension[]=common_admin_settings (or common_sites_settings if settings are for public sites)

Personnaly, i use the 'host' setup so i would not have been able to use the hack technique from Thomas.

For exemple my site is :<b>www.siteA.com</b>
The backoffice is :<b>backoffice.siteA.com</b>

Thanx everyone for this constructive help.

Martin

EZP is Great

Thomas Nunninger

Wednesday 04 January 2006 4:51:27 am

@Kristian: Ok, I need to look at this some more - but I thought that it would prepend the extension settings before the siteaccess settings.

@Martin: here's the patch :-)

@all:

Here's a patch for the "hierarchical siteaccess" (against 3.7.2). Originally I wanted to provide a possibility to define siteaccesses in a multi language environment. That is: you have a hierarchical siteaccess setting (e.g. project/public/eng/us - see above) and you can define general settings (like database) in project/, settings for the public siteaccesses in project/public/ and very special settings (here local settings) in project/public/eng/{us}. You can define general default settings which can be overriden by the special settings. (More comments cf. my previous posting in this thread).

--- ezini.php.org       2005-11-04 09:29:31.000000000 +0100
+++ ezini.php   2006-01-04 13:18:09.000000000 +0100
@@ -981,6 +981,36 @@
         if ( eZINI::isDebugEnabled() )
             eZDebug::writeNotice( "Changing override dir to '$dir'", "eZINI" );

+        // Patch for hierarchical siteaccess - start
+        // Author: Thomas Nunninger
+        // FIXME: I'm not sure if things like ezExtension::prependExtensionSiteAccesses work
+        //        correctly
+        // Probably now it's not possible to call a siteaccess "siteaccess" (or does the
+        // slash at the end of 'siteaccess/' prevent from problems? in combination with the
+        // following if?).
+        $siteAccessStartPos = strpos( $dir, 'siteaccess/' );
+        if ( false !== $siteAccessStartPos )
+        {
+            $siteAccessStartPos += 11;
+        }
+        if ( $siteAccessStartPos < strlen( $dir ) )
+        {
+            $siteAccess = substr( $dir, $siteAccessStartPos );
+            $siteAccesses = explode( '/', $siteAccess );
+            $path = substr( $dir, 0, $siteAccessStartPos - 1 );
+            $newDirs = array( );
+            foreach ( $siteAccesses as $siteAccess )
+            {
+                $path .= "/$siteAccess";
+                $newDirs[] = array( $path, $globalDir, $identifier );
+            }
+        }
+        else
+        {
+            $newDirs[] = array( $dir, $globalDir, $identifier );
+        }
+        // Patch for hierarchical siteaccess - end
+
         if ( $this->UseLocalOverrides == true )
             $dirs =& $this->LocalOverrideDirArray;
         else
@@ -1005,7 +1035,10 @@
         }

         if ( $overrideOverwritten == false )
-            $dirs = array_merge( array( array( $dir, $globalDir, $identifier ) ), $dirs );
+            // Patch for hierarchical siteaccess - start
+            // Author: Thomas Nunninger
+            $dirs = array_merge( $newDirs, $dirs );
+            // Patch for hierarchical siteaccess - end

         $this->CacheFile = false;
      }
@@ -1015,6 +1048,12 @@
     */
     function appendOverrideDir( $dir, $globalDir = false, $identifier = false )
     {
+        // Patch for hierarchical siteaccess - start
+        // Author: Thomas Nunninger
+        // Do I need to change this function for hierarchical siteaccess too?
+        // grep shows me no call of this function in the whole eZ code
+        // Patch for hierarchical siteaccess - end
+
         if ( eZINI::isDebugEnabled() )
             eZDebug::writeNotice( "Changing override dir to '$dir'", "eZINI" );

I haven't tested it in all possible situations. (Un)Known behavior:

- At the moment I only can say that it works for virtual setup. I know there's a problem with URI, because there is a regular expression in access.php replacing all non-alpha-numeric charactars (I had a patch against this if someone is interested)

- I didn't test if the siteaccess is really right, if you do things like the version view in the admin interface for different siteaccesses

- I hope there are no caching issues

- I don't know if there are problems with extension settings because I haven't tested it. But I tried a generic approach to cover even this situation.

Conclusion:

if you want to use this code: use it in any way and don't blame me if something's wrong.

Comments and experiences are wellcome. (And if you request more perhaps I extend/test this patch against the (un)known issues listed above.) Perhaps I'll create a contribution - if not everybody says: Oh my god, what have you done!

I also would enjoy if this would go in eZ publish 3.8 (and something similar in eZ publish 4 - because I think it can simplify life very much).

Thomas

Thomas Nunninger

Wednesday 04 January 2006 4:56:08 am

@Martin: I think you got me a little bit wrong. Host setup would be great :-)

Thomas

Esteban Rodriguez

Wednesday 04 January 2006 5:15:31 am

Thanks Again Kristian,

I hadn't thought of using an extension for this. It's definitely much better than modifying the original .ini settings. One thing less against our upgradeability.
Thanks for the help!

Esteban

I have great faith in fools; self-confidence my friends call it.

http://presencia.net

H-Works Agency

Wednesday 04 January 2006 5:23:09 am

Thanx a lot Thomas for your contribution...but i can't modify any default ezp files. I'd better add multiple time the same settings throughout my siteaccesses.

I am gonna use the Kristian extension's method that doesn't touch ezp php files.

Martin

EZP is Great

Thomas Nunninger

Wednesday 04 January 2006 5:39:52 am

Martin, yes, I've seen this. And probably it's the best way because you don't need to change many things.

I just wanted to post my patch because perhaps it's useful in any way or for future addition in eZ. I think it's a much smarter and more intuitive way than using an extension. I think it could be usefull as general way even in normal setups with just one admin and one user siteaccess because things like database setings, var directory, ... are only defined in one place. E.g. if someone wants to change the var directory it's not that easy to forget to change it in admin and user siteacces. Perhaps this is no problem for experienced users (even you can do spell errors in one siteaccess setting). But new users which do not have that overview about sideeffects when changing settings get some help in this way.

Thomas

H-Works Agency

Monday 09 January 2006 1:58:17 am

Ok Thomas thanks.

The answer on this point by Kristian is great !!! ('extension' technique).

It simplified my settings/siteaccess/mysite/*.ini a lot !!!

The greatest advantage is for override.ini files because you now just have to write your override directive once for all the site that will use it...this is really great.

I think the use of the 'extension' feature exposed here should be widely spread to all ezp users using ezp in a multiple sites environnement.

Martin Harispuru

EZP is Great

H-Works Agency

Thursday 02 March 2006 5:33:56 am

I am having a problem with my settings extension.

This extension is common to every "public" site.

My problem is with the "override.ini" files in this extension, in fact it supercede the override.ini directives in my /settings/siteaccess/$mysite/override.ini and i don't think that is a normal behavior.

In fact in my /settings/siteaccess/$mysite/override.ini i have :

ActiveAccessExtension="customs/settings/base_common/"

That loads :

$ezp/extension/customs/settings/base_common/settings/override.ini

As is use "ActiveAccessExtension", this file should be loaded AFTER my siteaccess one ?

Instead when both files have the same directive, for exemaple 'full_folder', its the one under "extension" that is taken making all my directives in /settings/siteaccess/$mysite/override.ini useless.

Shouldn't it be the one under my siteaccess ?

Thanx in advance for any help on this,

Martin

EZP is Great

Kristian Hole

Monday 06 March 2006 7:19:40 am

Hi Martin,

Override.ini is a special ini-file where position of the elements within the file matters. The main problem is that you most likely want to mix the overrides from your extension with the ones from the extension in between eachother. (I don't remember if the ones in the extension is added to the top or the bottom of the siteaccess one.)

With the current system that is hard to do, so i think the recommendation is to put your overrides in the siteaccess.

Kristian

http://ez.no/ez_publish/documenta...tricks/show_which_templates_are_used
http://ez.no/doc/ez_publish/techn...te_operators/miscellaneous/attribute

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.