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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Similar Content

    • By jom
      Chäs & Co is a b2b cheese trader. They love good cheese and are proud of their excellent knowledge und connections to small cheese producers. They maintain a custom made database and used to copy/paste (!) the cheese infos to the former CMS (Contao). Since substituting the database with ProcessWire was no option, they export now the database to a csv file and import it to the new website (expanded version of module ImportPagesCSV).
      From there, the pw magic begins. The staff works with the admin interface: They search and find products in notime using the build-in search field (using cheese names or id. Using ids only possible by adding hook, see this forum thread). They generate price lists easily based on a template, providing checkboxes and option buttons for some restrictions, choose i.e. the cheese origin and price audience (all implemented as page selectors). By saving the page a PDF list gets generated (using mpdf, a php pdf library).
      The visitors can sort and filter the products using a form by shuffle.js. Product details are shown in a popup (fancybox). There's also the option for generating a nice pdf data sheet. No CSS framework being used.
      Other modules used: ProcessJumpLinks, ProcessProMailer, ProcessWireUpgrade.
      Visual design: Nicole Haller


    • By Juergen
      Hello @ all,
      I am creating a new inputfield/fieldtype to store opening hours, but I am struggeling to save values from multiple dynamic created inputfields in 1 column of the database.
      Scenario:
      The user can enter one or more opening times per day in a UI.
      Fe:
      Monday open from 08:00 to 12:00 and from 14:00 to 17:00 Tuesday open from 08:00 to 12:00 and from 14:00 to 19:00 and so on
      Via a little JavaScript you can add as much opening times as you need per day - the additional inputfield will be created dynamically.
      After form submission all the values are in the POST array -> this works (see example below):
      ProcessWire\WireInputData Object ( [openinghours_mo-0-start] => 09:00 [openinghours_mo-0-finish] => 13:00 [openinghours_mo-1-start] => 14:00 [openinghours_mo-1-finish] => 18:00 [openinghours_mo-2-start] => 21:00 [openinghours_mo-2-finish] => 23:00 [openinghours_tu-0-start] => 09:00 [openinghours_tu-0-finish] => 13:00 [openinghours_tu-1-start] => 14:00 [openinghours_tu-1-finish] => 18:00 [openinghours_we-0-start] => 09:00 [openinghours_we-0-finish] => 13:00 [openinghours_we-1-start] => 14:00 [openinghours_we-1-finish] => 18:00 [openinghours_th-0-start] => 09:00 [openinghours_th-0-finish] => 13:00 [openinghours_th-1-start] => 14:00 [openinghours_th-1-finish] => 18:00 [openinghours_fr-0-start] => 09:00 [openinghours_fr-0-finish] => 13:00 [openinghours_fr-1-start] => 14:00 [openinghours_fr-1-finish] => 18:00 [openinghours_sa-0-start] => [openinghours_sa-0-finish] => [openinghours_so-0-start] => [openinghours_so-0-finish] => ) The property name is always the name attribute of the field 😉 . If the property is empty means closed on that day.
      Now I need to combine all those values into 1 array (or json array) and store it in the database in 1 column called 'hours' in my case (see screenshot below):

      In my ___processInput(WireInputData $input) method I have tried to make it work like this:
      public function ___processInput(WireInputData $input): self { $name = $this->attr('name'); $value = $this->attr('value'); //input object includes always every input on the page, so lets filter out only inputs from this field //we need to do this, because the number of values is variable - so extract only values that starts with $name.'_' $nameAttributes = []; foreach($input as $key=>$value){ if(substr($key, 0, strlen($name.'_')) === $name.'_'){ $nameAttributes[$key] = $value; } } // loop through all inputfields of this fieldtype $time_values = []; foreach($nameAttributes as $nameAttr => $value) { $time_values[$nameAttr] = $value; } } //save it in the database $input->set('hours', serialize($time_values)); return $this; } The only important part of this code is the last part with the serialize function.
      After saving it will create a record in the database, but the value is always NULL (default value) (see below).

      Checking $time_values returns all the values, but printing out "$this" shows me that the property "hours" inside the Openinghours object is empty (see below) - so the mistake must be there, but I dont know where?!?!?!?
      [title] => Home [openinghours] => ProcessWire\OpeningHours Object ( [data] => Array ( [hours] => ) ) If I check the sleepValue() method or the sanitizeValue() - they are also empty. So it seems that the values will not reach these methods. I havent found a clear documentation of whats going on behind the saving process of an inputfield.
      As far as I know the saving process starts with the form submission. The values are in the POST array and will be processed by the processInput() method. Before they will be saved in the database they will be sanitized by the sanitizeValue() mehtod and afterwards they will be prepared for storage in the sleepValue() method.  The last step is the storage itself.
      Has someone an idea what is missing by storing values from multiple fields into 1 database column or has someone a working example of such a scenario on github to help me out.
      A clear explanation of the storage process will be also helpful.
      Thanks and best regards
    • By Pip
      Hi Everyone 
      I've been working on Processwire for two months now. Structuring the website as needed. Unsure why but I'm getting this one now. Seems my fields has crashed. 
      I've tried googling some answers but can't seem to find a step by step guide on how to rectify this. Any advise? Practically new on this. 
      TIA. 

    • By Rodd
      Hi everyone!
      I have a website in a production environment and I want to duplicate it in a local environment. I exported the content of the website (with the 'Site Profile Exporter' module) but I cannot use it actually. I've got an issue with the database. I imported this one in MAMP then.

      I also exported the pages (with the 'ProcessPagesExportImport' module), but I cannot import it to my local website because the fields don't exist. So I created this fields, but I have this error :
      How can I use the elements that already exist and are presents in my database? How can I duplicate correctly the templates, fields and pages?
      Thanks by advance
      PS: Sorry if my english is bad
       
    • By Peter Troeger
      Hello Community 🙂
      Has anyone ever tried having multiple elements on one page that get their info with $pages->find('selector, limit=n') and tried using pagination on one of these elements without effecting the other?
      I have a slider on a page where I display content with pagination. But when I go to page two, the slider content also goes to page two, which I don't want it to do 🙂
      Any tips are greatly appreciated!
      Thanks!
      -Peter
×
×
  • Create New...