Jump to content

Two domains, same content, two sets of templates?


Lance O.
 Share

Recommended Posts

Is the following concept possible using ProcessWire?

1. The mobile version of a site would reside at m.exampledomain.com and the desktop version at exampledomain.com

2. The mobile version would use responsive web design, and the desktop version would not.

3. The mobile version would have a limited experience, displaying less content and functionality than the desktop version of the site.

4. Both sites would use a single database, maintained using only one ProcessWire Admin. There wouldn't be a set of separate fields for each site; instead both sites would use the same set of fields from the same single database.

5. Each site would use a different set of ProcessWire templates.

The concept here is that the client maintains the desktop version and the content is used in two sets of templates (mobile and desktop). This is different than using responsive web design and presenting the same set of templates differently for both mobile and desktop.

Link to comment
Share on other sites

This is simple and you can do it like this:

Have the subdomain dns point to the same root as the domain.

In the Template you could use:

if($_SERVER['SERVER_NAME'] == 'm.exampledomain.com'){
    include('yourmobile_tpl.php');
} else {
    include('yourdesktop_tpl.php');
}

or whatever you can make out of it, you can also just define a constat or variable to use in code.

  • Like 2
Link to comment
Share on other sites

I've got a proof of concept up and running. (Note that I will probably take this down at some point, so apologies ahead of time for any broken links.)

Desktop site: http://prcss.info

Mobile site: http://m.prcss.info

If you visit the desktop site on a mobile device, you should be automatically forwarded to the mobile site. I'm using the detection script mentioned earlier in this thread. The detection script is only installed on the desktop site.

Notice that the "Desktop Header/Desktop Footer" text changes to "Mobile Header/Mobile Footer" depending on the domain from where you are viewing the site. I used Soma's code to switch out the header and footer.

I've added an image and internal link to the Home page to make sure that those links work correctly on both sites.

To point the subdomain to the main domain, I changed the Document Root in cPanel to /public_html


A BIG thanks to Soma for pointing me in the proper direction. As with all things ProcessWire, the best solution is usually the easiest.

  • Like 1
Link to comment
Share on other sites

If I use this snippet (taken from http://processwire.com/talk/topic/2956-two-domains-same-content-two-sets-of-templates/?p=29139 )

Thank you Soma!

if($_SERVER['SERVER_NAME'] == 'mywebsite.com'){
    include('this_template.php');
} elseif ($_SERVER['SERVER_NAME'] == 'mywebsite.net') {
    include('that_template.php');
}

Then I could in theory operate my site like a multisite, and provide different content based on which template is being served?!

Link to comment
Share on other sites

Desktop site: http://prcss.info
Mobile site: http://m.prcss.info
 
If you visit the desktop site on a mobile device, you should be automatically forwarded to the mobile site. I'm using the detection script mentioned earlier in this thread. The detection script is only installed on the desktop site.

THAT IS VERY COOL.

I'm seriously looking to do something like that.

Link to comment
Share on other sites

I think it is a good alternative to the client who only has a budget for a desktop site, but wants to later add a mobile site. Instead of redeveloping the desktop site using responsive web design (one of my personal nightmares), it would be much easier to just develop a mobile responsive site at a different domain.

  • Like 1
Link to comment
Share on other sites

I think it is a good alternative to the client who only has a budget for a desktop site, but wants to later add a mobile site. Instead of redeveloping the desktop site using responsive web design (one of my personal nightmares), it would be much easier to just develop a mobile responsive site at a different domain.

Adapting sites to a responsive design can be difficult depending on the layout. There's a heap of responsive frameworks you conceivably wrap your site with. Here's a reasonable roundup of frameworks that might interest you.

With my own site I recently used Toast to make it responsive. I previously used categorizr to detect which templates to serve mobile and desktop - which has its benefits in situations where you don't want/need to serve javascript to mobile devices. The other great thing about categorizr is you could have a link to enable mobile users to switch to the desktop version - and back again if they wished.

  • Like 1
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
 Share

×
×
  • Create New...