If you have been following my previous textpattern mobile site versions you may be pleased to know that I have new and more solid method of creating a mobile site but on a subdomain, still using the same database.
This must be on the same host to match the root folder. Either copy the files below to you sub domain or download my commented files and upload.
Here is what I did for the files on the subdomain
depends on how your file was in the first place but mine was standard I turned on the rewritebase /
rewritebase /
All your images that you have uploaded or use will be on the original domain, so when you are on the subdomain all relative links won’t work due to them not being on the subdomain url. So I added a redirect line to grab the images from the main domain url
redirect /images/ http://www.mysite.com/images/
I assume this would work for files and css etc…
I changed one line here on line 18 to define the txpath back to original site root overriding the config.php file txpath (see file).
Add this file to both root folders, on the original domain and the sub domain.
This was the pain in the arse one! I have tried the current timthumb.php file at darrenhoyt.com but did not work. For some reason had a different version (attached) running on oliverker.co.uk which has some different code around line 532 where I added the original domain and this seems to work.
I use timthumb to resize images and it is placed in my root web folder. When I use timthumb I use upm_image and usually which uses the site url set in the admin prefs, which leads me on to the next part…
In the txp admin preferences DELETE the site url so it displays nothing. Textpattern auto defaults to the current domain url so if you browsing the sub domain it will use a relative link rather than linking back to the main website.
I use a page template to determine the device/domain and then use forms to place the content in where needed. My form is much more complicated than this and yours will be too, but I have simplified it for you to use.
In the download files I have put a commented version of the code below
<?php
include('mobile_device_detect.php');
$mobile = mobile_device_detect(true,false,true,true,true,true,true,false,false);
?>
<!DOCTYPE HTML>
<html>
<txp:ied_if_domain domain="sub.domain.com">
<head>
<txp:output_form form="iphone-head" />
</head>
<body >
<txp:output_form form="iphone-body" />
</body>
<txp:else/>
<head>
<txp:output_form form="head" />
</head>
<body>
<?php if($mobile==true): ?>
<a class="trymobile" href="http://sub.domain.com">Try the mobile specific site?</a>
<?php endif; ?>
<txp:output_form form="body" />
</body>
</txp:ied_if_domain>
</html>
If your user needed to get back to the main website then it is probably a good idea to have a link on the mobile site somewhere that links back to the main website.
Only tested in 4.2.0
iphone, mobile, sub domain, textpattern
Comments