Jump to content

Multisite


apeisa

Recommended Posts

Sounds like I'm going to need this module. But I have a few questions:

I'm a big fan of the XML sitemap plugin.. anyone have experiences using these two plugins together?

Are urls like http://domain/subdomain/article redirected to http://subdomain.domain/article 

if someone hovers the link does it show http://domain/subdomain/article ? or http://subdomain.domain/article ?

Link to comment
Share on other sites

From memory the XML sitemap class doesn't check for multisite needs, though I seem to recall someone asking this before and maybe even posting some altered code (I might have dreamed that bit thouugh!).

Link to comment
Share on other sites

Can I use and test out this module locally ie. using MAMP?

Some basic instructions would be great!

Also if I use it on a live host can I install processwire with the multisite module in a subfolder before I move it into the root?

Link to comment
Share on other sites

I don't use MAMP, but what you have to basicly is this:

1) Install ProcessWire with for example the domain maindomain.localhost which points to /Arjen/Sites/maindomain.com/.

2) Make sure it's working fine and install the Multisite plugin.

3) Create an entry in your virtual host file and point that domain to the domain in step 1. For example point seconddomain.localhost to /Arjen/Sites/maindomain.com/ as well.

4) Now both maindomain.localhost and seconddomain.localhost will load the same website.

5) Follow instructions above.

Link to comment
Share on other sites

I have pretty mixed feelings about this module myself. It does work (well, there is one user where it doesn't and I don't have a clue why), but all should be aware that there are many things to consider:

  • Complexity grows exponentially with each subsite you add. More templates, more fields, more pages
  • Your coding needs to be different if the site is subsite: $page->rootParent isn't actually rootParent, but the home. 
  • www.campaign-site.com/processwire/ admin isn't there, it is only at www.main-site.com/processwire/
  • Maybe not compatible with all the modules. Ie. form builder works, but you need to create new /form-builder/ page under each of your subsites.
  • Cross linking doesn't work yet. Ie. if you use get or find to find pages from other subsites, then echo $p->url() won't give the right url (this is should be actually easy fix, but not yet fixed)

If your subsite is big, I don't think using this module is good idea. For simple marketing campaign sites I think this is fine way to go, but for larger sites I would consider other approaches.

  • Like 2
Link to comment
Share on other sites

only the homepage of the subdomain works for me.

if I try go to:

subdomain.site.com/yadayada/

nothing happens. see:

corporate.ccw-global.com

www.ccw-global.com

Edit: I ended up moving the subdomain back to having it's own database. It might be more hassel to admin, but simpler to ensure good SEO with two different XML sitemaps. I had a few instances where /domain/subdomain/ due to the way pages were linked.

Anyways, I'll look forward to when this module gets beefed up, or when a next gen version gets released.

Link to comment
Share on other sites

I think we should consider a new module which covers some more functions. The concept of contexts in MODX for example is pretty straight forward (in theory). So I think something like this would be nice to have:

- define any desired rootParent as own context

- every context can have its own context settings (for example domain or even own alias with the same domain as the root, language, id of own 404 etc.)

- In your templates you could just refer to these settings via $context->my_setting

- the url creation has to be implemented with a hook (path::after?) so it works everywhere

- cross context linking should work (so TinyMCE has to tweaked I guess)

- fields, templates etc. can be shared between contexts (organisation via the new tag function)

- [...]

I think it is a very common use case to have several websites (domains) in one environment, so this would be awesome if we would have a module which considers all these "problems" and would work out of the box. So we could claim PW as "multi language, multi domain" without tweaking  ;)

Unfortunately this is beyond my PHP skills :-

  • Like 1
Link to comment
Share on other sites

The aims seem to be:

  • One site folder
  • One templates folder (which is where it gets messy)
  • One admin interface
  • Potential to share information across sites by calling something like $pages->context('sitename')->find('selector'); - This is the best way I can think of making it work anyway

I'm trying to do this without the time to draw a diagram, but the way I would see a new module working would be something like this:

  1. Have a single wire folder
  2. Have a /site/contexts/ folder, each site has its own folder within containing templates for that context (that way you could ignore the original templates folder)
  3. Write some API code to do something like $pages->context('sitename')->find('selector');
  4. DON'T show all the sites in one tree in the admin - no need, just have a drop-down at the top-right somewhere to switch between contexts
  5. Give them the option NOT to share the same database if desired. This then caters for marketing mini-sites to share the same DB but larger sites to be separate, as well as allowing for complete separation of templates and fields if desired (useful for creative studios with many sites)

This addresses all the requirements I think. There are a few compromises, but this ticks off the main aims I listed and doesn't over-complicate matters.

What do you guys think? MODx contexts made my brain hurt so I'm throwing this idea out as something that's hopefully simpler to setup, understand and manage :)

Other considerations are:

  1. You need some way of having single sign-on to switch between contexts (let's just call them sites hey? I'm getting confused every time I type that :D) if you use the separate databases approach
  2. Someone needs to add some functions into the API to make this work the way I described above, but I think that's possible :)
  3. Also the selectors could just be like $site->get('sitename')->pages->find('selector') but I like my first idea better :P Maybe $pages->site('sitename')->find('selector') though since I've totally gone off the term "contexts" now.
  4. Of course if you don't specify the site() part then it will default to the site that the template file is in.#
  5. And anything else you can think of...
  • Like 1
Link to comment
Share on other sites

Okay, haven't read the entire thread so I may have this completely upside down, but isn't it easier to have multiple Site folders with the first one as a default?

So, in each subsequent site it will use the templates in its own folder if they exists, if not it uses the templates from the default folder. Same for modules and admin template. There would have to be some exceptions, probably, so you didn't end up with the head from your own site1 folder and the footer from the default site folder, for instance.

But it might make deleting sites easier if it is just removing their entire site folder. Also means that they could be transferred to another installation, I would think ... somehow.

  • Like 2
Link to comment
Share on other sites

That is the exactly same bug that I haven't been able to solve yet. I am pretty sure it has something to do with server settings. It modifies the url fine, but still loads the homepage only. Strange. Does anyone have any clue about this? Also notice this: http://corporate.ccw-global.com/it/doesnt/throw/404/

yeah, I noticed... well since I switched back to 2 databases, that link now throws a 301 to the root :)

Link to comment
Share on other sites

The sites I was thinking of using this multisite module has mainly product pages that need to be shared. So if someone updates a product PDF file it is reflected on both sites. These product pages will have body text, couple of tables of data text, images to download and PDF files. There are also other downloadable files in other areas of the site, employee contact lists and resources that would ideally be shared too.

What options do i have to share content like this if multisite is not suitable?

Link to comment
Share on other sites

  • 1 month later...

I have one question about method #1; Is there an easy way to keep all of the backend translation in one place (wire folder?). I have multiple sites, installed as written in method 1, which have their own (json) language files for the backend translation but they seem to be saved seperate within each site-folder. In my case this isn't necessary so I'm curious in which file to change the location where the language variables are retrieved.

Link to comment
Share on other sites

The language translation files are considered part of the site's files rather than ProcessWire's core files, so they have to live in /site/assets/files/.../ rather than anywhere else. I suppose you could always make a symlink to set them up somewhere else. But I wouldn't bother with that unless it's creating an obstacle to have them the way they are. 

Link to comment
Share on other sites

Hi Ryan, well in this scenario (multiple sites with the same backend), it's more convenient to have them stored and maintained in one place so when we add some 'core functionality' which should be available for all sites, it would be more time consuming to update all of the different language-folders instead of just one. But I'll look into a way to use the symlink-option, thanks ;)

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

I would like to use this module but my PW installation produces the same error which Arjen described on the first page:

I can reach the page using the following URL:

http://www.maindomain.com/www.seconddomain.com/testpage/
But I can't reach the page using this URL:

http://www.seconddomain.com/testpage/

I followed the step by step explanation he described but still have no success getting the module to work.

If I open subdomain1.domain.com it redirects to the correct path of the tree and renders the menu as it should. The menu contains links like subdomain1.domain.com/festival, which seems correct to me. But all those links lead to the home page of the current subdomain, so in this case subdomain1.domain.com.

I read the whole thread and learned that this module is far from perfect but I need a way to manage four subdomains which use nearly the same templates from one PW installation. There is no other convenient way except for this module, right?

Link to comment
Share on other sites

I'm not really sure why it might not be working in your case, but it definitely doesn't sound right. It reminds me a bit of what one sees if they are trying to run ProcessWire without an htaccess file. What version of ProcessWire? Also, double check that those links have a trailing slash in them. The one you mentioned did not have a trailing slash, and I suspect that this module would require them. 

Link to comment
Share on other sites

Hi Ryan,

the links added to the module settings do not have a trailing slash. However, if i add one the module stops working since it fails to match the entry to the appropriate page on the second level.

I do have a .htaccess file but I am currently running the page in a local environment via MAMP. I am using the current ProcessWire Version 2.3.0.

I don't know why this should be an issue, but I will perhaps try to run it on my web hosting to make sure it does not have a problem with running local.

Link to comment
Share on other sites

Ezeey, I experiencing the same behaviour as my previous post. Did you manage to get it up and running?

Could it be that a previous fix has been reversed? It doesn't seem so though when looking at the github history.

Link to comment
Share on other sites

I got it working, but it is very hackish and definately should be looked after. I will fork apeisa's code tomorrow and try to figure out why my current version does work and the latest on github won't. For now you can check if this gist works for you. It does for me. It's an old version of the module I installed on my local machine at home. Then I changed some code with the new version. I didn't fix one warning, just placed an @ before it to stop the warning.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...