Forums / Setup & design / Multiple Siteaccess/Design Solution

Multiple Siteaccess/Design Solution

Author Message

Russell Michell

Moderated by: Nicolas Pastorino

Tuesday 15 September 2009 4:42:54 pm

Hi everyone,

After about a day of fun with ini files, and from several other forum posts on the subject, I have finally figured a way to get multiple siteaccess going on a single eZ 4.1.3 install, with:

- Independent CSS
- Independent templates
- Independent images
- Independent javascript files

I am using ez 4.1.3 with ezwebin 1.4.2, but this should still apply to at least all in the 4.1.x series. Note that I am using the host match method with a new hostname pointing to each siteaccess - this is just for clarity (I've seen too many uses of 'ezwebin_whatever' as siteaccess names which confuses the hell out of me), but this will equally work with the port match or any other matching method.

The 'secret' although it shouldn't really have come to this - is a combination of the "extension directory method" and the "design directory method":

1). Create all your siteaccesses in the settings/siteaccess directory as normal.
2). In the 'extension' directory, create a new empty directory for each extension-siteaccess and name identically to your siteaccesses.
3). Inside each new empty extension-siteaccess directory create empty 'design' and 'settings' directories.
4). Copy the entire extension/ezwebin directory into each of your new 'design' directories.
5). Create a fresh design.ini.append.php in each of your new 'settings' directory. For now it should contain only the following:

[ExtensionSettings]
# my-design-1 is obvousely an example, use your own siteaccess name here:
DesignExtensions[]=my-design-1

6). Create an empty directory in eZ's root 'design' directory named identically for each of your siteaccesses.
4). Inside each of these new directories, create softlinks/symlinks/shortcuts to each of the ezwebin 'resource' directories (<i>images</i>, <i>stylesheets</i>, <i>javascript</i>, <i>templates</i>) located within the appropriate extension directory.

<b>Your directory structure should roughly look like this:</b>

+ ezpublish
 +-- settings
  +-- override
  +-- siteaccess
   +-- my-design-1
   +-- my-design-2
   +-- my_admin
 +-- extension
  +-- ezwebin
  +-- my-design-1
   +-- design
    +-- ezwebin
   +-- settings
    -- design.ini.append.php
  +-- my-design-2
   +-- design
    +-- ezwebin
   +-- settings
    -- design.ini.append.php
 +--design
  +-- admin
  +-- base
  +-- my-design-1
   -- images -> /path/to/ezpublish/extension/my-design-1/design/ezwebin/images
   -- javascript -> /path/to/ezpublish/extension/my-design-1/design/ezwebin/javascript
   -- templates -> /path/to/ezpublish/extension/my-design-1/design/ezwebin/templates
   -- stylesheets -> /path/to/ezpublish/extension/my-design-1/design/ezwebin/stylesheets
  +-- my-design-2
   -- images -> /path/to/ezpublish/extension/my-design-2/design/ezwebin/images
   -- javascript -> /path/to/ezpublish/extension/my-design-2/design/ezwebin/javascript
   -- templates -> /path/to/ezpublish/extension/my-design-2/design/ezwebin/templates
   -- stylesheets -> /path/to/ezpublish/extension/my-design-2/design/ezwebin/stylesheets

Now edit these specific parts of site.ini.append.php in settings/override and in each of your settings/siteaccess directories:

<b>override/site.ini.append.php:</b>

[ExtensionSettings]
ActiveExtensions[]
ActiveExtensions[]=my-design-1
ActiveExtensions[]=my-design-2
ActiveExtensions[]=ezwebin
ActiveExtensions[]=ezodf
ActiveExtensions[]=ezoe
ActiveExtensions[]=ezdeploy
ActiveExtensions[]=ezurlaliasmigration

[SiteSettings]
# Nothing here

[DesignSettings]
AdditionalSiteDesignList[]
AdditionalSiteDesignList[]=ezwebin

[SiteAccessSettings]
MatchOrder=host
HostMatchType=map
HostMatchMapItems[]=design1-my-domain.co.nz;my-design-1
HostMatchMapItems[]=design2-my-domain.co.nz;my-design-2
HostMatchMapItems[]=my-domain.co.nz:8095;my_admin
CheckValidity=false
# To remove index.php from all URLs
ForceVirtualHost=true

<b>siteaccess/my-design-1/site.ini.append.php:</b>

[ExtensionSettings]
# Nothing here

[SiteSettings]
SiteName=Design 1
SiteURL=design1-my-domain.co.nz
LoginPage=embedded
AdditionalLoginFormActionURL=http://my-domain.co.nz:8095/my_admin/user/login
# Use the object id of the content-object you wish to see as the main page/entry-point to this siteaccess
# Hint: You can get this by mousing over it in the admin siteaccess
IndexPage=/content/view/full/347
DefaultPage=/content/view/full/347
RootNodeDepth=2

[SiteAccessSettings]
PathPrefix=<Title of folder used as root node in 'IndexPage' and 'DefaultPage' settings above>
PathPrefixExclude[]=Media
AvailableSiteAccess[]=my-design-1
AvailableSiteAccess[]=my_admin

[DesignSettings]
SiteDesign=my-design-1

<b>siteaccess/my-design-2/site.ini.append.php:</b>

[ExtensionSettings]
# Nothing here

[SiteSettings]
SiteName=Design 2
SiteURL=design2-my-domain.co.nz
LoginPage=embedded
AdditionalLoginFormActionURL=http://my-domain.co.nz:8095/my_admin/user/login
# Use the object id of the content-object you wish to see as the main page/entry-point to this siteaccess
# Hint: You can get this by mousing over it in the admin siteaccess
IndexPage=/content/view/full/348
DefaultPage=/content/view/full/348
RootNodeDepth=2

[SiteAccessSettings]
PathPrefix=<Title of folder used as root node in 'IndexPage' and 'DefaultPage' settings above>
PathPrefixExclude[]=Media
AvailableSiteAccess[]=my-design-2
AvailableSiteAccess[]=my_admin

[DesignSettings]
SiteDesign=my-design-2

Clear your cache and check your sites!

Good luck,
Russ

Russell Michell, Wellington, New Zealand.
We're building! http://www.theruss.com/blog/
I'm on Twitter: http://twitter.com/therussdotcom

Believe nothing, consider everything.

André R.

Wednesday 16 September 2009 1:27:04 pm

You should be able to do it without the symbolic links and copying webin design (by not copying it you save your self a lot of work later when upgrading).
This is how:
* skip the symbolic links
* skip copying the files from ezwebin
1. In each of the extensions create the design name, like:
extension/my-design-1/design/my-design-1
2. Copy _only_ the files you want to edit/change in ezwebin and other design you might use (like standard) to the same exact path inside your own design (extension/my-design-1/design/my-design-1/templates/pagelayout.tpl)
3. if you copy a css file, make sure you also copy all the images it uses as image paths in css are relative.
4. In your siteaccesses make sure you setup properly the design order, like:

[DesignSettings]
SiteDesign=my-design-1
AdditionalSiteDesignList[]
# Uncomment this if your using ezflow
#AdditionalSiteDesignList[]=ezflow
AdditionalSiteDesignList[]=ezwebin
AdditionalSiteDesignList[]=base

If you in step 1 just call your design 'ezwebin' (or ezflow), then you don't need to think about step 4. BUT! you do have to care about extension loading in this case (you actually should anyway to make sure you can override settings in these extensions as well). And your examples gets it correct ( my-design-* is above ezwebin ).

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

Russell Michell

Thursday 17 September 2009 8:48:47 pm

Hi André,

Thanks for your feedback. I have at last, reverted my tree to how it should be according to your instructions. It wasn't quite as simple as you described, but this may due to my having done some 'custom' things along the way.

Cheers once again,
Russell :-)

Russell Michell, Wellington, New Zealand.
We're building! http://www.theruss.com/blog/
I'm on Twitter: http://twitter.com/therussdotcom

Believe nothing, consider everything.

Jamie E.

Monday 21 September 2009 11:09:38 am

Hi Russ, this was a great writeup. Would you consider incorporating what you learned from implementing André's suggested changes, expand on it a bit, and create an Article to be posted here on ez.no? That would be invaluable to new users like myself.

In my opinion, eZ Publish really needs more documentation like this: Concrete and specific, rather than general and vague.

Russell Michell

Sunday 27 September 2009 12:20:42 pm

Hi Jamie,

A good idea - I was thinking of doing the same myself. I have started such an article and hope to be able to submit it review to the eZ crew soon.

I need to make sure what I have is accurate and so will need to spend some time installing a fresh eZ install, and going through my own article - just to make sure it's 100% accurate!

Thanks a lot,
Russell

Russell Michell, Wellington, New Zealand.
We're building! http://www.theruss.com/blog/
I'm on Twitter: http://twitter.com/therussdotcom

Believe nothing, consider everything.

Nicolas Pastorino

Monday 01 February 2010 8:26:44 am

A related discussion popped up here : http://share.ez.no/forums/setup-design/siteaccess-vs-multiple-standalone-ez-instance-pros-cons-feedback

Cheers,

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

Peter Rudolfsen

Saturday 24 April 2010 2:24:05 pm

I've been working/thinking about this a bit now, and I think I've come up with a solution that'll enable you to have all your extensions and sites/siteaccesses structured outside of ez publish, and have a build script that'll do all the "hard work" setting up the installation for you, based on the extensions and siteaccesses you choose to include at that time. Which basically means that you can easily split them up into separate installations, or have them all in the same, whatever suits you (the site) best.

Here's the structure of the code outside of ez publish:

root

    extension
        custom_extension1
        custom_extension2

    sites
        sitename
            extension
                site_extension1
                site_extension2
            siteaccess
                sitename_eng
                sitename_admin

    build.xml
    build.properties

When you build this, it'll checkout / copy the core of eZ Publish and place it in a folder you choose and put all the extensions and siteaccess you wish to include (all, or a specified list), into the installation.

root / sites / sitename / extension goes into ez-installation / extension

root / sites / sitename / siteaccess goes into ez-installation / settings / siteacess

root / extension goes into ez-installation / extension

When you build this for development, the extensions and siteaccess will be symlinks inside the installation, but if you build if for production / distribution, it will copy each extension / siteaccess into the installation instead, so you're able to have each installation standalone, and isolated from each other.

You can take this even further, splitting settings into environment-specific folders (development, integration, preprod, production), and have the build-script copy/link the correct settings based on what you're building for.

The only downside I can see to this right now is that you have to be careful with the settings / override folder. You really shouldn't use it all, since it can potentially ruin every single installation you have. But you kind of should be careful with that folder anyway...

Any thoughts on this?

Greg McAvoy-Jensen

Tuesday 08 June 2010 4:28:34 pm

There is now a tutorial on this topic here.

Granite Horizon, Certified Developer of eZ Publish Web Solutions
Provider of the SaaS Solution Granite Horizon In The Cloud | http://granitehorizon.com/cloud
http://granitehorizon.com | +1 916 647 6350 | California USA | @granitegreg
Blog: http://granitehorizon.com/blog

Agoes Aswari

Friday 18 June 2010 4:55:14 am

Nice tutorial ...

I've done that tricks before when I was using eZPublish version 4.0.2.

But since I upgraded to eZ 4.2 and 4.3 now, I had a new problem, when I add a new extension site. I have to add PolicyOmitList[]=content/view into the site.ini.append.php in the extension/mysite/settings. Because if I don't do that, anonymous user can't read any content, they have to login although I has add role policy (content-read) from siteadmin.

So my question is, is it really necessary to add PolicyOmitList[]=content/view into the site.ini.append.php? Because at earlier version (4.0.2) I don't have to to that.

Sao Tavi

Friday 31 December 2010 8:31:45 am

Hey, guys

First of all, thank you for the tutorials! They are invaluable for creating new sites with ez publish, I do believe that eZ should give lot more attention to this area of their site.

Now, about my issue: I want to create a development section and an online section. Also, for the development section I want to create a new design. I am really new to eZ Publish, I jut set up a little site with it in which I let users from the old site know in what development stage is the new site. I currently have all the scripts I need for the actual site, I just have to implement them to eZ Publish.

So, I have my sections, one online, one for development (I have a folder as root node that contains 2 frontpages, one is the root node of standard section, the other the root node of development section). The new section was created from the admin control panel -> sections. I also created a new folder in settings/siteaccess that is just a copy of the eng folder, with some modifications. The problem is that I cannot link the section created in the control panel with the new folder (that should link to the custom design). I have added this to site.ini.append.php from the development siteaccess folder:

IndexPage=/content/view/full/118
DefaultPage=/content/view/full/118
...
SiteDesign=my_custom_design

Where 118 is the node id of the frontpage for development and my_custom_design is the name of the extension that includes the design (so it has a design/my_custom_design/templates folder). Also, I have added to content.ini.append.php:

[NodeSettings]
RootNode=118

Any help, please?

...........................................................

Later edit: after several hours of playing around, I realized that I forgot that I changed the settings/override/site.append.ini.php and that accessing the url from the sitelist[] created by me would automatically make the connections that I needed. So I now have the development version that nobody but admins will be able to access and I will be able to replace the site with the development version with only some clicks.