1 regular site + 1 mobile site, share content, different templates - Feedback

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
nhaack

1 regular site + 1 mobile site, share content, different templates - Feedback

Post by nhaack »

Hi there,

I am currently thinking about how to setup two sites with the same content under different sub-domains with different templates. And I like to hear your thoughts.

What for?

I want to have a site that features a lot of images (photography hobby) and text (misc. stuff) and plays around with javascript (esp. AJAX) available under e.g. http://www.domain.com.

At the same time, I want to offer a mobile site with the same contents under the sub domain http://mobile.domain.com. The mobile site should be reduced in media and script content to ease use and load faster (and increase compatibility). It should also be available by a separate sub-domain. The whole thing is not commercial - more of a private get to know how to do it :).

Different CSS Styles?

I decided against a pure CSS based solution since I want to use different template structure & images and less content blocks. I also want to have no javascript functionality on the mobile site. So basically, everything is the same, except for the templates used (which feature different CSS and html content generated by UDTs in some places).

Ok, How?

I though of two installation sharing the same content. Or more precisely, one looking at the content of the other installation but having own template DB table content. The number of templates wouldn't change, so I thought I could create views for all the database tables (except the templates table) of the mobile site pointing to the corresponding tables of the regular site.

The templates table of the mobile site would then have to be maintained individually (I don't know if CMSMS would let me login and alter the templates without having writing access to any other table). I would just have to ensure that I have the correct templates IDs and other fields and the same amount of templates.

Like this, I can maintain the content from one CMS (incl. UDTs etc) but provide two sites with adapted content. However, mobile template administration will be a careful hand job (ok... but you seldom change this when it's done).

Other ideas?

Alternatively I thought of getting the content for the mobile site with a plugin/tag accessing the other installation's DB. Or by getting it via RSS from the other site. But these options sound like a lot of unnecessary computing to me.

Template Switcher?

I also though of the template switcher plug in - but as far as I understood by quickly going over it, I would have parameters attached to my page, and users might have to choose which version to see. Mhh... I am just thinking, would it be possible to use the .htaccess to get the sub domain and use this as a parameter for the page call?

And now?

So you see. There are a lot of options. :-\ 

I'm going through all the pros and cons at the moment but probably someone of you already had a similar setup and can give some recommendation or directions. Do you see any problems with the database table view construction?

Cheers
Nils
nhaack

Re: 1 regular site + 1 mobile site, share content, different templates - Feedback

Post by nhaack »

===========
Edit:
I think I found a much better way to solve this. I described my solution here:
http://forum.cmsmadesimple.org/index.ph ... 495.0.html
===========


I thought "what the heck..." I'll give it a shot. So I took two installations and replaced most database tables of one installation with views to the other one.

A quick "hit and run" test revealed that it is at least possible.

This is what I did:

DOMAINS:
# map domain name to folder 1 on sever
# map sub domain name to folder 2 on server

INSTALL:
# install CMS 1 into folder 1 and database with table-prefix "cms_"
# install CMS 2 into folder 2 and same database with table-prefix "mobile_"

CONFIG:
# Add all plug-ins and modules you want to use to CMS 1
# Add regular templates to CMS 1

DATABASE MOD:
# delete all tables of CMS 2 (the ones with prefix "mobile_")
# create a view for each deleted table with original name for each table of CMS 1 (prefix "cms_")

Example mySQL command

Code: Select all

CREATE VIEW mobile_content 
AS SELECT * FROM cms_content
# Export tables "cms_templates" and "cms_templates_seq"
# import as "mobile_templates" and "mobile_templates_seq"

TEMPLATES:
# Log in CMS 2 with credentials of CMS 1 (the CMS 2 now looks at the corresponding folders of CMS 1 due to the views)
# Strip templates, modify templates

Afterwards I looked at both domains and got identically structured pages with different templates. All with the same URLs after the domain name. No parameter or client detection nor user input needed. However, you need to use absolute paths where needed to use the same files, alternatively, copy any extra files into the folders of CMS 2.

However, this solution is not the best in performance. Page output times for identical simple templates dropped from ~0.25 (CMS 1) to ~0.36 (CMS 2). But I think for mobile clients that will do. It won't be a high frequency site. When done, I guess the lesser use of plug-ins and modules in the mobile templates might compensate for the performance loss in comparison of both sites.

I need to play around with it a little more to check for ups and downs. I will let you know. If someone has another approach to get two sites to share content and use different templates, please post your ideas :)

Best
Nils
Last edited by nhaack on Sat Sep 06, 2008 1:41 am, edited 1 time in total.
Post Reply

Return to “Developers Discussion”