#1
Posted 04 March 2012 - 02:57 PM
What this module does?
It allows you to run multiple sites with different domains run from single install, using same database. While you can easily do "subsites" like www.domain.com/campaign/, this allows you to turn that into www.campaign.com. This is nice stuff, when you have multiple simple sites, that all belong to same organisation and same people maintain.
How to use it?
Just create page with name like www.campaigndomain.com under your homepage, then edit this module through modules menu and add same domain there. If your domain resolves to same place where your main domain, it should just work. Please notice that if you have editing rights, it allows you to browse the site from www.olddomain.com/www.campaigndomain.com/, but users with no editing rights are redirected to www.campaigndomain.com (this is because session cookie is otherwise lost).
Any problems?
Not any real problems, at least yet known. Of course think twice when deciding should the site have own install instead of this. There are few benefits, like getting data from other sites, one admin view for all sites etc... but it can easily get out of the hands: number of templates, fields etc.. It is harder to maintain for sure.
Isn't there multisite support in core?
Yes, kind of. It is very different from this. It allows you to run multiple pw-installations with shared core files (/wire/ folder). This is totally different: this is single pw-installation which has multiple sites running from different domains.
This is basically just a wrapper with one config field for this little snippet Ryan posted here: http://processwire.c...ndpost__p__5578 (so most of the credit goes to Mr. Cramer here). What it also does is that it manipulates $page->path / url properties to have right subdomain value.
#2
Posted 04 March 2012 - 05:11 PM
One suggestion that I have is to change this:
// If subdomain is visible on url, we might wanna redirect
if(strpos($_GET['it'],$subdomain) !== false) {
// We don't redirect if one has editing access (because user would need to login on new domain also)
$page = $this->pages->get("/". $_GET['it']);
if(!$page->editable()) {
$_GET['it'] = str_replace("{$subdomain}/", "", $_GET['it']);
$this->session->redirect('http://' . $subdomain . '/' . $_GET['it']);
}
}…to this (or something like it, as I've not actually tested, but hopefully the intention is there):
// saved $_GET['it'], since PW unsets it after using it
// note this is an unsanitized variable, so only look at it, don't use it
protected $it;
public function init() {
$this->subdomainsArray = explode("\n", strtolower($this->subdomains));
$this->it = ltrim($_GET['it'], '/');
// ...then your existing code…
}
public function ready() {
// if $this->subdomain was valid in init(), then no need to do more here.
if($this->subdomain) return;
$subdomain = $this->page->rootParent->name;
// if rootParent->name isn't a subdomain, then no need to continue
if(!in_array($subdomain, $this->subdomainsArray)) return;
// if subdomain is visible on url, we might wanna redirect
if(strpos($this->it, $subdomain) === 0 && !$this->page->editable()) {
$url = str_replace("/{$subdomain}/", '/', $this->page->httpUrl);
$this->session->redirect(url);
}
}
The point of this is to avoid sending an unfiltered $_GET['it'] into $pages->get(), which may contain anything in it at that point. There's always a security concern with sending unfiltered input to any function that isn't expecting it. You can avoid the issue completely by moving the check into the ready() function, which gets called after PW has already validated the URL and determined the page. If you wanted to get more fancy with it, you could also foreach($input->urlSegments) and append $input->pageNum (if > 1), but I really don't think that's necessary.
#3
Posted 04 March 2012 - 05:44 PM
#4
Posted 05 March 2012 - 12:44 PM
Oliver: you could definitely use this for m.domain.com type of stuff, actually a great use case for this module also. Many of our clients tend to have multiple smaller sites, that need to use data from main site, are maintained by same people, but usually have different marketing domain and own visuals. That is the original need for this module, but actually I would probably use this for m.domain.com type of mobile versions also.
#5
Posted 06 March 2012 - 10:59 AM
#6
Posted 12 April 2012 - 07:56 AM
Thx for help!
edit: I changed line 40 into:
if(strpos($httpHost, $subdomain) !== false && strpos($httpHost, 'admin') !== false) { which works for now. But I think this is not intended, so I would appreciate the "proper" solution ;-)
Another edit: How is the homepage supposed to work? Now it is the root page, but with several domains it would be nice to have several homepages (under the domain page or the domain page itself). What do you think?
Edited by MadeMyDay, 12 April 2012 - 09:48 AM.
#7
Posted 12 April 2012 - 01:55 PM
www.maindomain.com // This is the mainsite, runs just like any other pw-site
www.campaign.com // This is the first one using multisite, this domain is entered into module settings, but also as page under maindomain.com
www.anothercampaign.com // Just like the above
Admin for all these pages is accessible from www.maindomain.com/processwire/
First level of site tree from maindomain.com looks like this:
- About Us
- News
- Contact us
- Sitemap
- www.campaign.com (hidden)
- www.anothercampaign.com (hidden)
I won't suggest building very complicated setups with this, but it is superb for few specific campaign sites (especially if same people maintain or they reuse the data between). If you have many big sites under same site, you will end up with huge amount of templates & fields.
#9
Posted 07 October 2012 - 10:16 PM
So I suppose the question is if page in ProcessWire has to have unique Name or we might have got pages with the same names under different "Categories".
website.com/race1/first-place
website.com/race1/second-place
website.com/race2/first-place
website.com/race2/second-place
?
#10
Posted 07 October 2012 - 11:58 PM
If you were asking if this module is suitable for offering same content for differend devices, then it is not intention of this module and that could be done in template level.
#11
Posted 08 October 2012 - 05:07 AM
Thanks
#12
Posted 24 October 2012 - 12:42 PM
For our needs I had to implement support for alternative domains (each extra domain can have n alternatives, which all point to the same location.) With separate domains for development and secure addresses -- not to mention that in this case the client required alternative domains that couldn't be handled very well with just redirects -- that was pretty much the easiest way to put together a consistent experience.
So, basically I'm asking if you'd be interested in incorporating that addition in the main module if I sent you a pull request for it (of course once I've tested it properly first?)
#13
Posted 24 October 2012 - 02:21 PM
#15
Posted 19 November 2012 - 09:26 AM
1) Make sure all the traffic from www.seconddomain.com points to the home directory of the www.maindomain.com. (checked)
2) Install the module and make sure that www.seconddomain.com is added to the textarea. (checked)
3) Create a new page with the template 'home' with the title matching the domain - in this case www.seconddomain.com. Status of the page is published and hidden. (checked)
Then I thought I have to add another page to make this work:
4) Create a page with a template underneath the 'second' homepage called 'Testpage'. Status of the page is published.
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/
Things I've noticed
1. When I try to reach www.seconddomain.com it displays a 404 error.
2. The other items (like the primary navigation) on rootlevel are changed to www.seconddomain.com.
Thinking
Then I starting thinking (just about then
The idea
I got a very simple site with three pages and the client really liked to the idea to create some landing pages using other domains but using the same structure. Hence I thought apeisa's Multisite could be used here.
Many thanks for any thoughts!
#16
Posted 19 November 2012 - 12:06 PM
Just to confirm: if you do remove the domain from module settings, you can use www.seconddomain.com and browse the "root site" normally? Also www.maindomain.com/www.seconddomain.com/ works and you can access that page normally?
Then if you try www.seconddomain.com is the 404 error msg generated by PW or Apache? Does the module do any redirects? What is visible on addressbar? Feel fr-e to PM me any additional details if you want me to take closer look.
#17
Posted 20 November 2012 - 02:44 AM
If I browse:
http://www.maindomain.com/www.seconddomain.com/
it loads the seconddomain homepage.
The 404 error is generated by PW. It doesn't redirect when I try to reach:
http://www.seconddomain.com/testpage/
I am using this with some subdomains. Could that be the issue here? The root site is located at:
http://clientdomainname.clients.mysite.com/
I will PM you in a short moment.
#18
Posted 26 November 2012 - 02:27 PM
#19
Posted 28 November 2012 - 06:37 AM
with Options #1: multiple sites with multiple databases how
Sites can't easily share data with each other, since they are running independently from one another.
is hard?
I've 4 sites:
HQ (advertising and redirect to one of the children, in the future this control the newsletter sending operation and the main events calendar)
\_ site2
\_ site3
\_ site4
Site2 have the most users and contents.
Sites 2,3,4 can share a couple of "translator user".
HQ news/events must be viewed also in 2, 3 and 4.
Site2 specific news/events must be viewed in HQ, 3 and 4.
Only this.
Thanks,
Marco
Also tagged with one or more of these keywords: Module
Community Support →
Modules/Plugins →
Inline EditorStarted by Sinmok, 10 May 2013 |
|
|
||
Community Support →
Modules/Plugins →
Module: Site indexerStarted by Alessio Dal Bianco, 08 May 2013 |
|
|
||
Community Support →
Modules/Plugins →
Form Builder - Form with more than 1 formbuilderfile inputStarted by theGC, 07 May 2013 |
|
|
||
Community Support →
General Support →
How can I set/get module-data from DB when not implementing ConfigurableModule?Started by horst, 14 Apr 2013 |
|
|
||
Community Support →
API & Templates →
Programmatically change page template in modulesStarted by boundaryfunctions, 11 Apr 2013 |
|
|
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users













