#1 February 26, 2013 12:46pm

hellonicolas
Member
Registered: February 26, 2013
Posts: 1

Multi-site setup

Hi BigTree team! We're currently exploring BigTree for Bully's main site, intranet, and client extranet. In the interest of unifying our systems and minimizing the number of BigTree instances, we were kinda hoping to drive all those sites with one install.


One of the other reasons for this would be to create a sort of a global Project ecosystem – all 3 of those main sites will have some reference to a Client / Project, so we were thinking we'd create a table for that and reference that data from separate Modules.

  1. Do you have any recommendations on setup/structure for something like that within BigTree? My assumption was the individual sites' Home Pages under the main Home Page:
    HOME
        -MAIN SITE
            --Section 1
            --...etc
        -INTRANET
            --Section 1
            --... etc
        -EXTRANET
            --Section 1
            --...etc

    Does that kind of setup make sense?

  2. Does the need to have subdomains to separate these 'sites' complicate everything? wink

  3. Any other recommendations are welcome!

Thanks in advance!


-Nicolas (from Bully!)

Offline

#2 March 6, 2013 12:05pm

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 970

Re: Multi-site setup

Sorry for the delayed reply, I was out on vacation and I guess the rest of the team wanted my official response on this.

If all three "sites" are served from the same domain and you're OK with subdirectories for the "home" pages of the three sites than your assumption is by far the easiest way to make it happen. You can use the "trunk" option in Pages to specify your Main Site, Intranet, and Extranet "homepages" as the root of the site. By default, I believe, $cms->getBreadcrumb will read trunks as top level and ignore them when calling that method. If you want to get your top level navigation ID for drawing sub navigation while keeping the trunk in mind you have to call $cms->getToplevelNavigationId(true) - otherwise it will always return the Main Site / Intranet / Extranet homepage.

Using subdomains does indeed complicate things. Back in BigTree 3 I'd served multiple sites off a single BigTree install by hacking the main router to pretend that a certain Page ID was the homepage but I can't recall doing it recently. There are two things that need to be done to make that work:

  1. A custom router (/customrouter.php) that prepends your "homepage" route to $bigtree["path"]. So if your extranet would theoretically be http://www.website.com/extranet/ you would do $bigtree["path"] = array_merge(array("extranet"),$bigtree["path"]); somewhere before the if (!$navid) { line. This also kind of breaks previewing, but if that's the route you want to go I can whip up a custom router that integrates it all.

  2. A custom BigTreeCMS class extension that will strip out your extra path elements (extranet, main-site, intranet) from calls to getLink, getNavByParent, etc.

Support for this stuff natively will most likely be in a future BigTree release as it's pretty easy to implement but kind of hacky to do on your own right now. As for when that release will be, it could be a while as I'm buried in client work at the moment, but I'd be happy to help get your solution going if you have any questions.

Offline

#3 May 18, 2013 9:31am

asiral
Member
Registered: May 18, 2013
Posts: 43

Re: Multi-site setup

Hi, Tim:

I echo Nicolas's desire to use BigTreeCMS with multiple sites.  I was wondering if you had any more specific advice on how to implement this using subdomains?  Our organization is keen to use BigTreeCMS and we likely will, but it would be ideal if it supported multiple sites on different subdomains.  Our requirements are pretty flexible but we'd like to be able to share some resources (styles, templates, etc.) while keeping other resources, like images, accessible only behind the domains for which they're intended.  By flexible, among other techniques, I mean that we can use rewrite or links to reference resources to enforce the separation for example.

My hopeful self is telling me that there's some clever solution but without full knowledge of the system, I am only grasping in darkness at times for how best to do this.

Also, do you know when version 4 might be out of RC and if the final release will include this support?

Thanks,
Michael

Offline

#4 May 19, 2013 3:51pm

asiral
Member
Registered: May 18, 2013
Posts: 43

Re: Multi-site setup

Hi, Tim:

I thought I'd share my experience with the community.  Indeed, after trying some cleverness using Rewrites and Aliases, I turned to the code and it lead me to do exactly what you outlined.

I'm using three subdomains: one is used for administrators to publish content and two are separate intranet sites.  In the custom router, array_merge was not working because the '0' index is blank at times and merging the arrays leaves, for example, the '0' index filled but pushes the blank to the '1' index and causes errors.  Instead, if the '0' index was not blank, I performed "array_unshift" (but "array_merge" would have worked), otherwise I just set the '0' index.  I expect this wouldn't be a problem if I never accessed the parent page of the trunks serving these intranet branches, but for completeness, I've mentioned this.

I also had to edit the config.php. The method I used is to check the host of the request and depending on the subdomain, setting the root URLs in the config array.

Finally, I overrode the getNavByParent and getLink methods using a custom method, getAdjustedPath.

My trials seem to be working well.  Can you see anything I am missing, including methods from the BigTreeCMS class?  Would editing the config.php as I did cause any errors I have not yet encountered?

I'll update this thread with my progress if I make further customizations.  Thanks for your previous notes!

-Michael

Offline

#5 May 20, 2013 9:32am

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 970

Re: Multi-site setup

Michael,

That sounds great, glad it's working for you! I can't think of anything you're missing off the top of my head but if you run into any problems I'd be happy to help. Thanks for sharing your solution!

Offline

#6 May 22, 2013 3:26am

asiral
Member
Registered: May 18, 2013
Posts: 43

Re: Multi-site setup

One other method that seems to complete the changes is an update to getInternalPageLink.

-Michael

Offline

#7 May 22, 2013 11:59am

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 970

Re: Multi-site setup

Good catch! I completely forgot about that one.

Offline

#8 May 24, 2013 4:18pm

asiral
Member
Registered: May 18, 2013
Posts: 43

Re: Multi-site setup

Hi, Tim:

I noticed something else.  In our multi-site setup, these sites will likely share resources as the design is unified but
the content is for the most part separate. One trouble was the router checking for a cached file.

Because it replaces URLs in the styles and JavaScript, it would serve the last cached file to domain A but it would contain URLs from the domain for which it was cached, say domain B.  So I simply appended the $_SERVER['HTTP_HOST'] to the cached file name, $cfile, in the router processing for styles and JavaScript.

Thanks again,
Michael

Offline

#9 May 27, 2013 9:39am

timbuckingham
Administrator
From: Baltimore, MD
Registered: April 2, 2012
Posts: 970

Re: Multi-site setup

Nice workaround! We've never done a site that uses all the same /site/ and /cache/ resources so these are great new perspectives for us if we ever run into that in the future. When we've powered multiple sites from the same "install" it's only been a shared database with separate BigTree templates/folders. Awesome to see it doing things we never expected!

Offline

#10 June 7, 2013 9:23am

asiral
Member
Registered: May 18, 2013
Posts: 43

Re: Multi-site setup

I should have expected this but it's a little more complicated still.

You'll also need to pass the path retrieved in the breadcrumb function to the getAdjustedPath function mentioned above.

Offline

Board footer

Powered by FluxBB

The Discussion Forum is not available on displays of this size.