I want my website to load an iphone template set once the iphone useragent is detected, similar to sixaparts iphone plugin iMT for the administrative panel.
Is this an easy task to accomplish? Any directions?
I’m using dynamic publishing
Reported on Movable Type 4.2
The easiest solution I can think of involves static publishing. What I would do is create a second set of templates for the iphone, and include some PHP code at the top of the pages that looks like this:
<?php
if ( stristr($_SERVER["HTTP_USER_PAGE"], "iPhone") >= 0)
header("Location:
<$MTBlogURL$><$mt:FileTemplate format="%y/%m/%-F-iphone.php" encode_xml="1"$>");
?>
Here is the documentation for the FileTemplate tag: http://www.movabletype.org/documentation/appendices/tags/filetemplate.html
I would recommend trying this out on a test installation of Movable Type and tweaking that PHP until you get it right for each template type. By the way, static publish has much better performance than dynamic publishing, and dynamic publishing usually doesn't provide enough benefits to justify the cost.
Crap, that should read HTTP_USER_AGENT
For dynamic publishing, you can use a similar technique to what Mike described. You can set a MT template variable that you can then test for anywhere in your templates. Place the following in your header template, or some module that is processed before anything else:
Then, elsewhere in your MT templates, you can use a MT 'if' tag like this:
(load an iphone stylesheet, for instance)
(load regular browser stylesheet)