Archives
Master Symfony2 fundamentals
Symfony hosting done right
Discover the SensioLabs Support
Blog
How to create an optimized version of your website for the iPhone in symfony 1.1
by
Fabien Potencier
– June 09, 2008
– 36 comments
symfony 1.1 introduces native support for different formats and mime-types. This means that the same model and controller can have different templates based on the requested format. The default format is still HTML but symfony supports several other formats out of the box as defined in the factories.yml file:
request:
class: sfWebRequest
param:
formats:
txt: text/plain
js: [application/javascript, application/x-javascript, text/javascript]
css: text/css
json: [application/json, application/x-json]
xml: [text/xml, application/xml, application/x-xml]
rdf: application/rdf+xml
atom: application/atom+xml
Each format is associated with one or more mime-types. These mime-types are used to automatically determine the requested format by parsing the Accept HTTP header. This comes in very handy if you want to make your data available via a browser and expose them as a Web Service. To change the format of the response, a Web Service client can just change the Accept header as shown below:
$ curl -H "Accept: application/xml" http://ws.example.com/api/article # to get a XML representation of the data
$ curl -H "Accept: application/json" http://ws.example.com/api/article # to get a JSON representation of the data
Supporting different formats is as easy as creating different templates. So, let's say the web service is managed by an api/article action. Here is the list of templates you have to create in apps/frontend/modules/api/templates to support HTML, XML, and JSON formats:
- articleSuccess.php
- articleSuccess.xml.php
- articleSuccess.json.php
By default, symfony will change the response Content-Type according to the format, and for all non-HTML formats, the layout will be disabled. Even partials and layouts can be different based on the requested format. For example, if you include a list partial in a template, the loaded partial name will depend on the current format:
- _list.php
- _list.xml.php
- _list.json.php
Let's take another example. You want to create some stylesheets or JavaScript files on the fly. As you can't always rely on the browser Accept HTTP header for those cases, you can force a format by using the special sf_format variable in your routing rules. Here is how to create a route for a dynamic stylesheet:
css1:
url: /css/dynamic1.css
param: { module: css, action: dynamic, sf_format: css }
You can also use the sf_format variable in the URL pattern to allow several formats for one action:
api_article:
url: /api/article.:sf_format
param: { module: api, action: article }
requirements:
sf_format: (?:html|xml|json)
Most of the time, you don't have to change a single line in your actions to support new formats; but if you really need to do something special for a format, you can call the $request->getRequestFormat() to get the current format and act accordingly.
Ok, now for the fun part! Let's say you want to create an optimized version of your website for the iPhone. The iphone format does not exist by default but it's pretty easy to configure one. First, we need a way to determine that a request comes from an iPhone. If the User-Agent header contains the words Mobile and Safari, we can safely guess that the browser is an iPhone. We can put this logic in the ProjectConfiguration class by registering a listener for the request.filter_parameters event:
// config/ProjectConfiguration.class.php class ProjectConfiguration extends sfProjectConfiguration { public function setup() { // ... $this->dispatcher->connect('request.filter_parameters', array($this, 'filterRequestParameters')); } public function filterRequestParameters(sfEvent $event, $parameters) { $request = $event->getSubject(); if (preg_match('#Mobile/.+Safari#i', $request->getHttpHeader('User-Agent'))) { $request->setRequestFormat('iphone'); } return $parameters; } }
Now, everytime a request comes in, the filterParameters() method is called and if the browser is an iPhone, the request format is changed to iphone.
That's all! Now, every request from an iPhone will use *Success.iphone.php templates instead of *Success.php templates.
If you use some special stylesheets of JavaScript files to support the iPhone (for example if you use the iui library), you can also configure the view by listening to the view.configure_format:
class ProjectConfiguration extends sfProjectConfiguration { public function setup() { // ... $this->dispatcher->connect('view.configure_format', array($this, 'configureIPhoneFormat')); } public function configureIPhoneFormat(sfEvent $event) { if ('iphone' == $event['format']) { // add some CSS, stylesheet, or whatever you want } } }
Today, Apple launched the new iPhone 2. To celebrate this event, I'm pleased to announce that the symfony API documentation is now available for the iPhone with a specific interface as you can see in the screenshot below.

Thanks to the new format support in symfony 1.1, developing websites that supports Web Services, API or the iPhone has never been easier. Supporting a new format is as easy as creating a new set of templates. Enjoy!





is a trademark of Fabien Potencier. All rights reserved.
Add a Comment
Comments
sf still the best
Thank you for this beautiful framework!
Is not just a framework, is a way of life!
Thank you!
The method name, 'filterRequestParameters' doesn't match the one in your connect call, 'filterParameters'.
I needed to replace '$dispatcher' with '$this->dispatcher' - maybe that was implied by '// ...'?
And you also need to create a layout called 'layout.iphone.php'.
:)
Other than that -- it's gorgeous!
// config/ProjectConfiguration.class.php
class ProjectConfiguration extends sfProjectConfiguration
{
public function setup()
{
// ...
$this->dispatcher->connect('request.filter_parameters', array($this, 'filterRequestParameters'));
}
public function filterRequestParameters(sfEvent $event, $parameters)
{
$request = $event->getSubject();
if (preg_match('#Mobile/.+Safari#i', $request->getHttpHeader('User-Agent')))
{
$request->setRequestFormat('iphone');
}
return $parameters;
}
}
Looking forward to start using 1.1.
Do validators work with this?
Is there some docs on customizing sfProjectConfiguration and an explained list of those events like view.configure_format you can modify?
http://www.symfony-project.org/book/1_1/17-Extending-Symfony#Built-In%20Events
I'm looking forward to the 1.1 stable release.
I presume the iPhone stuff is identically working for the iPod-Touch as well, as the latter is based on the same software system as the iPhone (e.g. Mobile Safari)?
Cheers RAPHAEL
url: /api/article:.sf_format
should be:
url: /api/article.:sf_format ?
04316. <a href=http://blogs.ign.com/BadCreditOk/2007/09/20/66790/><b>Alternative Student Loans Bad Credit</b></a>
04874. <a href=http://blogs.ign.com/philvgordon/2008/03/12/83695/><b>Very Bad Credit Personal Loans</b></a>
04950. <a href=http://blogs.ign.com/charlesbojanen/2008/03/14/83835/><b>Bad Credit High Loan Personal Risk Unsecured</b></a>
05363. <a href=http://blogs.ign.com/robertlnebel/2008/04/01/85550/><b>Free Mp3 Ringtones</b></a>
06489. <a href=http://blogs.ign.com/lorrieacclark/2008/04/22/87440/><b>Free Samsung T100 Ringtones</b></a>
07057. <a href=http://blogs.ign.com/partner55346429/2008/05/06/88882/><b>Annual Credit Report Free</b></a>
07633. <a href=http://kverizonringtones.weebly.com/><b>Ringtones For Verizon Cell Phones</b></a>
08753. <a href=http://blogs.ign.com/catherinemponder/2008/05/22/90597/><b>Ringophone Verizon Polyphonic Ringtones</b></a>
0882. <a href=http://blogs.ign.com/christamstewart/2008/05/22/90599/><b>Download Free Polyphonic Ringtones</b></a>
04340. <a href=http://blogs.ign.com/BadCreditOk/2007/09/20/66790/><b>Guaranteed Bad Credit Student Loans</b></a>
04885. <a href=http://blogs.ign.com/philvgordon/2008/03/12/83695/><b>Free Bad Credit Personal Loans</b></a>
04995. <a href=http://blogs.ign.com/charlesbojanen/2008/03/14/83835/><b>Find Unsecured Personal Loans For Very Very Bad Credit</b></a>
05315. <a href=http://blogs.ign.com/robertlnebel/2008/04/01/85550/><b>Lg Ringtones</b></a>
06429. <a href=http://blogs.ign.com/lorrieacclark/2008/04/22/87440/><b>Free Ringback Ringtones</b></a>
07044. <a href=http://blogs.ign.com/partner55346429/2008/05/06/88882/><b>National Free Credit Report</b></a>
07655. <a href=http://kverizonringtones.weebly.com/><b>Free Downloadable Ringtones For Verizon</b></a>
08780. <a href=http://blogs.ign.com/catherinemponder/2008/05/22/90597/><b>Free Ringtones For Verizon Customers</b></a>
08874. <a href=http://blogs.ign.com/christamstewart/2008/05/22/90599/><b>Free Download Ringtones</b></a>
04345. <a href=http://blogs.ign.com/BadCreditOk/2007/09/20/66790/><b>Alternative Student Loans For Students With Bad Credit</b></a>
04816. <a href=http://blogs.ign.com/philvgordon/2008/03/12/83695/><b>Personal Loans Bad Credit</b></a>
0495. <a href=http://blogs.ign.com/charlesbojanen/2008/03/14/83835/><b>Instant Approval Unsecured Personal Loans For Bad Credit</b></a>
05380. <a href=http://blogs.ign.com/robertlnebel/2008/04/01/85550/><b>Free Cell Phone Ringtones</b></a>
06445. <a href=http://blogs.ign.com/lorrieacclark/2008/04/22/87440/><b>Free Christian Ringtones</b></a>
07045. <a href=http://blogs.ign.com/partner55346429/2008/05/06/88882/><b>Free Instant Credit Reports</b></a>
0768. <a href=http://kverizonringtones.weebly.com/><b>Ringtones Free Verizon</b></a>
08731. <a href=http://blogs.ign.com/catherinemponder/2008/05/22/90597/><b>Making Ringtones For Verizon Phones</b></a>
08894. <a href=http://blogs.ign.com/christamstewart/2008/05/22/90599/><b>Free Mobile Ringtones Download</b></a>
04366. <a href=http://blogs.ign.com/BadCreditOk/2007/09/20/66790/><b>Bad Credit Loan Student</b></a>
04822. <a href=http://blogs.ign.com/philvgordon/2008/03/12/83695/><b>Bad Credit Personal Loan For Auto Purchase</b></a>
04931. <a href=http://blogs.ign.com/charlesbojanen/2008/03/14/83835/><b>Unsecured Personal Loans Bad Credit Uk</b></a>
05392. <a href=http://blogs.ign.com/robertlnebel/2008/04/01/85550/><b>Totally Free Ringtones</b></a>
06456. <a href=http://blogs.ign.com/lorrieacclark/2008/04/22/87440/><b>Free Nokia 1260 Ringtones</b></a>
07052. <a href=http://blogs.ign.com/partner55346429/2008/05/06/88882/><b>Free Annual Credit Reports</b></a>
07649. <a href=http://kverizonringtones.weebly.com/><b>Verizon V3M Ringtones</b></a>
08716. <a href=http://blogs.ign.com/catherinemponder/2008/05/22/90597/><b>Ringtones For Verizon Phones</b></a>
08860. <a href=http://blogs.ign.com/christamstewart/2008/05/22/90599/><b>Download Free Poly Ringtones</b></a>
0431. <a href=http://blogs.ign.com/BadCreditOk/2007/09/20/66790/><b>Alternative Student Loans Bad Credit</b></a>
04861. <a href=http://blogs.ign.com/philvgordon/2008/03/12/83695/><b>Personal Loans For Bad Credit Repair</b></a>
0496. <a href=http://blogs.ign.com/charlesbojanen/2008/03/14/83835/><b>Bad Poor Horrible Credit Unsecured Personal Loans</b></a>
05379. <a href=http://blogs.ign.com/robertlnebel/2008/04/01/85550/><b>Free Samsung Ringtones</b></a>
06459. <a href=http://blogs.ign.com/lorrieacclark/2008/04/22/87440/><b>Free Cellphone Ringtones</b></a>
07022. <a href=http://blogs.ign.com/partner55346429/2008/05/06/88882/><b>My Free Credit Report</b></a>
07652. <a href=http://kverizonringtones.weebly.com/><b>Verizon Kyocera Cell Phone Ringtones</b></a>
08715. <a href=http://blogs.ign.com/catherinemponder/2008/05/22/90597/><b>Thehonorsystem Free Verizon Ringtones</b></a>
08895. <a href=http://blogs.ign.com/christamstewart/2008/05/22/90599/><b>Download Free Cingular Ringtones</b></a>
04398. <a href=http://blogs.ign.com/BadCreditOk/2007/09/20/66790/><b>School Guaranteed Bank Student Loans Bad Credit</b></a>
0486. <a href=http://blogs.ign.com/philvgordon/2008/03/12/83695/><b>Bad Credit Long Term Personal Loans</b></a>
04956. <a href=http://blogs.ign.com/charlesbojanen/2008/03/14/83835/><b>Guaranteed Unsecured Personal Loan</b></a>
05353. <a href=http://blogs.ign.com/robertlnebel/2008/04/01/85550/><b>Free Composer Ringtones</b></a>
06466. <a href=http://blogs.ign.com/lorrieacclark/2008/04/22/87440/><b>Free Samsung Keypress Ringtones</b></a>
07040. <a href=http://blogs.ign.com/partner55346429/2008/05/06/88882/><b>Free Government Credit Report</b></a>
07632. <a href=http://kverizonringtones.weebly.com/><b>Free Ringtones For Verizon Cellular Phones</b></a>
08764. <a href=http://blogs.ign.com/catherinemponder/2008/05/22/90597/><b>Polyphonic Ringtones Verizon Wireless</b></a>
08839. <a href=http://blogs.ign.com/christamstewart/2008/05/22/90599/><b>Free Download Nokia Ringtones</b></a>
04331. <a href=http://blogs.ign.com/BadCreditOk/2007/09/20/66790/><b>Maine Student Loans For Students With Bad Credit</b></a>
0483. <a href=http://blogs.ign.com/philvgordon/2008/03/12/83695/><b>Instant Online Guaranteed Approval Personal Loans Bad Credit</b></a>
04965. <a href=http://blogs.ign.com/charlesbojanen/2008/03/14/83835/><b>Guaranteed Unsecured Personal Loans</b></a>
05343. <a href=http://blogs.ign.com/robertlnebel/2008/04/01/85550/><b>Free Nokia Ringtones</b></a>
0649. <a href=http://blogs.ign.com/lorrieacclark/2008/04/22/87440/><b>Free Actual Song Ringtones</b></a>
07016. <a href=http://blogs.ign.com/partner55346429/2008/05/06/88882/><b>Free Yearly Credit Report</b></a>
07631. <a href=http://kverizonringtones.weebly.com/><b>Free Ringtones For Motorola Verizon</b></a>
08722. <a href=http://blogs.ign.com/catherinemponder/2008/05/22/90597/><b>Coolfreeringtones Verizon Polyphonic Ringtones</b></a>
08842. <a href=http://blogs.ign.com/christamstewart/2008/05/22/90599/><b>Free Ringtones Download To Pc</b></a>
<a href="http://www.partsprovider.net">Car DVD</a>
<a href=http://www.partsprovider.net>HID Kits</a>
04372. <a href=http://blogs.ign.com/BadCreditOk/2007/09/20/66790/><b>Credit Card Loan Bad Credit Mortgage Auto Student Business</b></a>
04875. <a href=http://blogs.ign.com/philvgordon/2008/03/12/83695/><b>Apply Bad Credit Easy Loans Personal</b></a>
04955. <a href=http://blogs.ign.com/charlesbojanen/2008/03/14/83835/><b>Unsecured Fixed Rate Personal Loans</b></a>
05328. <a href=http://blogs.ign.com/robertlnebel/2008/04/01/85550/><b>Motorola V60 Free Ringtones</b></a>
06420. <a href=http://blogs.ign.com/lorrieacclark/2008/04/22/87440/><b>Free No Catch Ringtones</b></a>
0708. <a href=http://blogs.ign.com/partner55346429/2008/05/06/88882/><b>Consumer Free Credit Report</b></a>
07614. <a href=http://kverizonringtones.weebly.com/><b>Free Verizon Polyphonic Ringtones</b></a>
08769. <a href=http://blogs.ign.com/catherinemponder/2008/05/22/90597/><b>Ringtones For Verizon Cell Phones</b></a>
0884. <a href=http://blogs.ign.com/christamstewart/2008/05/22/90599/><b>Motorola Download Free Ringtones</b></a>
04322. <a href=http://blogs.ign.com/BadCreditOk/2007/09/20/66790/><b>Free Student Loans With Bad Credit</b></a>
04894. <a href=http://blogs.ign.com/philvgordon/2008/03/12/83695/><b>Same Day Personal Loans For People With Bad Credit</b></a>
04988. <a href=http://blogs.ign.com/charlesbojanen/2008/03/14/83835/><b>Unsecured Personal Loans Bad Credit No Home</b></a>
05348. <a href=http://blogs.ign.com/robertlnebel/2008/04/01/85550/><b>Free Polyphonic Ringtones USA</b></a>
06440. <a href=http://blogs.ign.com/lorrieacclark/2008/04/22/87440/><b>Free At&T Ringtones</b></a>
07013. <a href=http://blogs.ign.com/partner55346429/2008/05/06/88882/><b>Linkall Order Free Consumer Credit Report Bureau Check Score</b></a>
07667. <a href=http://kverizonringtones.weebly.com/><b>Ringtones For Verizon Wireless</b></a>
08743. <a href=http://blogs.ign.com/catherinemponder/2008/05/22/90597/><b>Verizon Music Ringtones</b></a>
08892. <a href=http://blogs.ign.com/christamstewart/2008/05/22/90599/><b>Samsung Ringtones Free Download Ring Tones For Cell Phone</b></a>
09374. <a href=http://freenokiaringtones.weebly.com/><b>Download Free Ringtones</b></a>
0949. <a href=http://downloadfreeringtones.weebly.com/><b>Free Gospel Ringtones</b></a>
09559. <a href=http://onlyfreemobilephoneringtones.weebly.com/><b>Free Cell Phones Ringtones</b></a>
09665. <a href=http://freecellphonesringtones.weebly.com/><b>Totally Free Ringtones</b></a>
0430. <a href=http://blogs.ign.com/BadCreditOk/2007/09/20/66790/><b>Student Loans For Students With Bad Credit</b></a>
0484. <a href=http://blogs.ign.com/philvgordon/2008/03/12/83695/><b>Unsecured Personal Loan Bad Credit</b></a>
0495. <a href=http://blogs.ign.com/charlesbojanen/2008/03/14/83835/><b>Personal Credit Hard Money Unsecured Loans</b></a>
05324. <a href=http://blogs.ign.com/robertlnebel/2008/04/01/85550/><b>Free Virgin Mobile Ringtones</b></a>
06425. <a href=http://blogs.ign.com/lorrieacclark/2008/04/22/87440/><b>100% Free Ringtones</b></a>
07020. <a href=http://blogs.ign.com/partner55346429/2008/05/06/88882/><b>Totally Free Credit Report</b></a>
07680. <a href=http://kverizonringtones.weebly.com/><b>Verizon Ringback Ringtones</b></a>
08771. <a href=http://blogs.ign.com/catherinemponder/2008/05/22/90597/><b>Free Ringtones For Verizon Wireless Samsung Sch A650 Phones</b></a>
08846. <a href=http://blogs.ign.com/christamstewart/2008/05/22/90599/><b>Wap Sites To Download Free Samsung Ringtones</b></a>
04344. <a href=http://blogs.ign.com/BadCreditOk/2007/09/20/66790/><b>Private Student Loans For Bad Credit</b></a>
04814. <a href=http://blogs.ign.com/philvgordon/2008/03/12/83695/><b>Bad Credit Loan Personal Unsecured</b></a>
04961. <a href=http://blogs.ign.com/charlesbojanen/2008/03/14/83835/><b>Buy Cheap Unsecured Personal Loans Bad Credit</b></a>
05392. <a href=http://blogs.ign.com/robertlnebel/2008/04/01/85550/><b>Totally Free Ringtones</b></a>
06497. <a href=http://blogs.ign.com/lorrieacclark/2008/04/22/87440/><b>Free Download Nokia Ringtones</b></a>
07053. <a href=http://blogs.ign.com/partner55346429/2008/05/06/88882/><b>Experian Check Free Credit Report</b></a>
07687. <a href=http://kverizonringtones.weebly.com/><b>Can You Get Ringtones For A Verizon Camera Phone</b></a>
08796. <a href=http://blogs.ign.com/catherinemponder/2008/05/22/90597/><b>Free Ringtones For Verizon Wireless Customers For Lg Phones</b></a>
08851. <a href=http://blogs.ign.com/christamstewart/2008/05/22/90599/><b>Download Free Real Music Ringtones</b></a>
04376. <a href=http://blogs.ign.com/BadCreditOk/2007/09/20/66790/><b>Private Bad Credit Student Loans</b></a>
04811. <a href=http://blogs.ign.com/philvgordon/2008/03/12/83695/><b>Personal Bad Credit Loan</b></a>
04942. <a href=http://blogs.ign.com/charlesbojanen/2008/03/14/83835/><b>Bad Credit Unsecured Personal Loans Online Instantly</b></a>
05383. <a href=http://blogs.ign.com/robertlnebel/2008/04/01/85550/><b>Free Ringtone Converter</b></a>
06427. <a href=http://blogs.ign.com/lorrieacclark/2008/04/22/87440/><b>Free Nokia 5125 Ringtones</b></a>
07093. <a href=http://blogs.ign.com/partner55346429/2008/05/06/88882/><b>Free Instant Credit Report</b></a>
07667. <a href=http://kverizonringtones.weebly.com/><b>Verizon Get It Now Ringtones</b></a>
08757. <a href=http://blogs.ign.com/catherinemponder/2008/05/22/90597/><b>Ringtones For Verizon Wireless Phones</b></a>
08834. <a href=http://blogs.ign.com/christamstewart/2008/05/22/90599/><b>Download Free Mp3 Ringtones</b></a>
09228. <a href=http://jackwrobertson.tigblog.org/post/388359><b>Totally Free Ringtones</b></a>
04317. <a href=http://blogs.ign.com/BadCreditOk/2007/09/20/66790/><b>Guaranteed Student Loan People Bad Credit</b></a>
04810. <a href=http://blogs.ign.com/philvgordon/2008/03/12/83695/><b>Secured Personal Loans For People With Bad Credit</b></a>
04993. <a href=http://blogs.ign.com/charlesbojanen/2008/03/14/83835/><b>Personal Unsecured Bad Credit Loans</b></a>
05387. <a href=http://blogs.ign.com/robertlnebel/2008/04/01/85550/><b>Free Mp3 Ringtones</b></a>
0648. <a href=http://blogs.ign.com/lorrieacclark/2008/04/22/87440/><b>Free Ringtones For Virgin Mobile</b></a>
07070. <a href=http://blogs.ign.com/partner55346429/2008/05/06/88882/><b>Free Credit Report No Credit Card Required</b></a>
07671. <a href=http://kverizonringtones.weebly.com/><b>Polyphonic Ringtones For Verizon Wireless</b></a>
08739. <a href=http://blogs.ign.com/catherinemponder/2008/05/22/90597/><b>Free Verizon Ringtones</b></a>
08825. <a href=http://blogs.ign.com/christamstewart/2008/05/22/90599/><b>Free Download Free Ringtones</b></a>
09236. <a href=http://jackwrobertson.tigblog.org/post/388359><b>Keypress Ringtones</b></a>
04338. <a href=http://blogs.ign.com/BadCreditOk/2007/09/20/66790/><b>Bad Debt Loan Student Credit</b></a>
04822. <a href=http://blogs.ign.com/philvgordon/2008/03/12/83695/><b>Bad Credit Loan Personal Unsecured</b></a>
04930. <a href=http://blogs.ign.com/charlesbojanen/2008/03/14/83835/><b>Bad Credit Unsecured Loan Personal Loan</b></a>
05372. <a href=http://blogs.ign.com/robertlnebel/2008/04/01/85550/><b>Mosquito Ringtone</b></a>
06444. <a href=http://blogs.ign.com/lorrieacclark/2008/04/22/87440/><b>Free Mp3 Ringtones</b></a>
07044. <a href=http://blogs.ign.com/partner55346429/2008/05/06/88882/><b>Free Online Credit Report No Credit Card Needed</b></a>
07685. <a href=http://kverizonringtones.weebly.com/><b>Coolfreeringtones Verizon Ringtones</b></a>
08782. <a href=http://blogs.ign.com/catherinemponder/2008/05/22/90597/><b>Gospel Ringtones Free Motorola V265 Verizon</b></a>
08890. <a href=http://blogs.ign.com/christamstewart/2008/05/22/90599/><b>Samsung Ringtones Free Download Ring Tones For Cell Phone</b></a>
09229. <a href=http://jackwrobertson.tigblog.org/post/388359><b>Free Verizon Ringtones</b></a>
04332. <a href=http://blogs.ign.com/BadCreditOk/2007/09/20/66790/><b>Bad College Credit Loan Personal Student</b></a>
04844. <a href=http://blogs.ign.com/philvgordon/2008/03/12/83695/><b>Bad Credit Long Term Personal Loans</b></a>
04932. <a href=http://blogs.ign.com/charlesbojanen/2008/03/14/83835/><b>Bill Consolidation + Unsecured Personal Loan</b></a>
05352. <a href=http://blogs.ign.com/robertlnebel/2008/04/01/85550/><b>Real Sound Ringtones</b></a>
06455. <a href=http://blogs.ign.com/lorrieacclark/2008/04/22/87440/><b>Free Samsung T100 Ringtones</b></a>
07075. <a href=http://blogs.ign.com/partner55346429/2008/05/06/88882/><b>Government Legislation Free Annual Credit Report</b></a>
07645. <a href=http://kverizonringtones.weebly.com/><b>Samsung Verizon Ringtones</b></a>
08722. <a href=http://blogs.ign.com/catherinemponder/2008/05/22/90597/><b>Verizon Kyocera Cell Phone Ringtones</b></a>
08870. <a href=http://blogs.ign.com/christamstewart/2008/05/22/90599/><b>Download Free Ringtones Voicemail Messages</b></a>
09253. <a href=http://jackwrobertson.tigblog.org/post/388359><b>Free Ringtones Verizon</b></a>
04342. <a href=http://blogs.ign.com/BadCreditOk/2007/09/20/66790/><b>Free Student Loans With Bad Credit</b></a>
04856. <a href=http://blogs.ign.com/philvgordon/2008/03/12/83695/><b>Small Bad Credit Personal Loans</b></a>
04968. <a href=http://blogs.ign.com/charlesbojanen/2008/03/14/83835/><b>Bad Credit Loans Unsecured Personal</b></a>
05370. <a href=http://blogs.ign.com/robertlnebel/2008/04/01/85550/><b>Ringtones For A Samsung</b></a>
06417. <a href=http://blogs.ign.com/lorrieacclark/2008/04/22/87440/><b>Free Hip Hop Ringtones</b></a>
07067. <a href=http://blogs.ign.com/partner55346429/2008/05/06/88882/><b>Free Online Credit Reports With No Credit Card Required</b></a>
07657. <a href=http://kverizonringtones.weebly.com/><b>Free Ringtones Verizon Wireless Phones</b></a>
08775. <a href=http://blogs.ign.com/catherinemponder/2008/05/22/90597/><b>Free Verizon Wireless Ringtones</b></a>
08853. <a href=http://blogs.ign.com/christamstewart/2008/05/22/90599/><b>Thumbplay Free Download Nokia Ringtones</b></a>
09232. <a href=http://jackwrobertson.tigblog.org/post/388359><b>Free Tracfone Ringtones</b></a>
One may make a site for small screens. But to make a site for a specific device is really bad practice.
And the iPhone support @media CSS-rules. That should be the first choice if you want to arrange stuff for the small screen. Incidentally that also is supported by Opera and will be by Firefox 3.1 and therefore also Fennec.
Using the wrong tool for a job is not a good route to go down, even if that tool is really well designed.
a. If your pages are so bloated that you must use different HTML output I would presume you need serious IA refactoring.
b. The very point of Apples marketing is that the iPhone should not get mobile specific versions of a website. And they specifically chose not to honor @media handheld but uses @media screen rules. By using such a device a customer has chosen to view the full version. Ergo: use "@media screen and max-width()" if you need to adapt.
Incidentally, that will also work for all users of Opera Mini (which is a larger audience than the iPhone's!) and Opera Mobile, as well as the upcoming Fennec.
c. UA sniffing has been proven beyond all reasonable doubt to be a faulty solution. It will only lead to UA-spoofing. We really have been there before! To repeat a previous mistake but expect a different outcome is just plain stupid.
So:
If you really must send alternate content to mobile devices (not just the iPhone), the least sucky solution is to use a different URL and let the user choose.
Of course that can lead to surprises when the mobile version ranks higher on Google. Just like many sites using the faulty approach of having "print versions" experience today.
But as I said to begin with. If your IA is bad, that is where you should attack the problem. It is better than creating new ones.