Hey Sniper,
Long-time no post (by me, that is). I've made a couple of tweaks to my mobile theme and I submit them here for your consideration.
I'll post the first one here and the other(s) in a follow up post.
1) IOS has the ability to let a mobile website look and behave just as a regular app would. This is fairly well-known. But I have a (mostly) fix for a problem facing phpbb sites. But first some house cleaning
If you include the link tags and meta tags below, you can have a custom thumbnail and splash screen too. The image size for the icon should be 114x114 pixels. The resolution for the splashscreen (high resolution version) should be 640x960 pixels.
- Code: Select all
<link rel="apple-touch-icon" href="img/icon.png"/>
<link rel="apple-touch-startup-image" sizes="640x960" href="img/splash-screen-640x960.png" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
After this is set up, you just have to click the center button at the bottom of Mobile safari (like you are going to bookmark the site). Instead of selecting bookmark, click "Add to Home Screen." This will add the icon to your home screen and remove the Safari Chrome (the url bar at the top and the status bar at the bottom of the page.) This gives you a lot more viewable screen real estate. But there is still one big problem.
If you click on any links from the page, it leaves the webapp and opens the new link in Mobile Safari. Which really defeats the purpose of creating the webapp in the first place.
The solution I've found requires the use of the jquery javascript library. You can add the google-hosted version of the library to your site by adding the following line in the head section of overall_header.html file.
- Code: Select all
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js" type="text/javascript"></script>
(Alternately, you can download the library and host it on your own server, if you prefer)
Next, below that line of code, you'll want to add this:
- Code: Select all
<!-- code below keeps links from leaving iOS webapp -->
<script type="text/javascript">
var weblinks;if(!weblinks){weblinks=window.onload=function(){function fullscreen(){var a=document.getElementsByTagName("a");for(var i=0;i<a.length;i++){if(a[i].className.match("noeffect")){}else{a[i].onclick=function(){window.location=this.getAttribute("href");return false}}}}function hideURLbar(){window.scrollTo(0,0.9)}weblinks.init=function(){fullscreen();hideURLbar()};weblinks.init()}}
</script>
<!-- code above keeps links from leaving iOS webapp -->
Essentially what this does is it rewrites standard hrefs that look like this:
- Code: Select all
<a href="http://ibm.com">IBM</a>
So that the links target the same window and have the behavior as if they were written like this:
- Code: Select all
<a href="javascript:window.location.href='http://ibm.com'">IBM</a>
This code, by the way, is sort of like finding the Holy Grail for iOS web app developers. There are lots and lots of folks complaining about this. But I've found few places that had any real solution. So I would expect you'll get a lot of traffic even from folks not developing for phpbb.
Now this is great and my site now looks and acts just like a real iOS app, with the exception of one phpbb-specific problem that I'm still trying to solve -- Pagination.
The Pagination links (specifically, the numbers) are generated in a different fashion and still take users out of the web app. This is the section in the pagination.html template that generates those links (the other links can be manually modified):
- Code: Select all
{PAGINATION}
What I'm trying to achieve is something like this (pseudo-code):
- Code: Select all
<a href="javascript:window.location.href='http://URL_GOES HERE'">1</a><a href="javascript:window.location.href='http://URL_GOES HERE'">2</a>
, etc
Or, alternately,
- Code: Select all
<a href="http://ibm.com" target="_self">1</a><a href="http://ibm.com" target="_self">2</a>
I'd appreciate if someone could point me in the right direction on how to fix these links. This solution is now 99 percent of the way complete.
If you do create an iOS webapp, one issue you'll need to address is how users can navigate back and forth on your site.
You can add back buttons to your site by adding the following bit of code
First go to viewforum_body. Find this line:
- Code: Select all
<td colspan="2">
<!-- IF S_DISPLAY_POST_INFO and not S_IS_BOT -->
Just above that add the following code:
- Code: Select all
<tr>
<td colspan="2">
<input class="button" type="button" value="Back" onclick="history.back(-1)">
</td>
</tr>
Next, add the same code just below the following lines:
- Code: Select all
<a href="{U_POST_NEW_TOPIC}"><strong>{L_POST_NEW_TOPIC}</strong></a>
</td>
</tr>
In viewtopic_body.html
Find the following line:
- Code: Select all
<td align="{S_CONTENT_FLOW_BEGIN}" class="gensmall">
Just above that, add this code:
- Code: Select all
<tr>
<td colspan="2"><input class="button" type="button" value="Back" onclick="history.back(-1)"></td>
</tr>
Next, find this:
- Code: Select all
<tr>
<!-- IF S_DISPLAY_POST_INFO -->
<td align="{S_CONTENT_FLOW_BEGIN}">
You'll want to add the same code just above those lines.
Finally, you can style that back button by adding the following code to your mobile theme:
- Code: Select all
/* mobile button style*/
.button {
font-family: Helvetica ;
font-weight: bold ;
padding: 15px;
border: 1px solid black ;
-moz-border-radius: 8px ;
-webkit-border-radius: 8px ;
margin-top: 10px ;
margin-bottom: 10px ;
background-color: white ;
}
Other than the pagination issue, it's great being able to view the mobile site as if it is a real web app. These changes don't harm other mobile browsers, (if their browser doesn't support javascript, the urls are not rewritten. No harm, no foul) so there is no problem implementing these solutions on your mobile site. But they add a nice touch (pun intended) to the iOS user experience.
[edit: Now that I think about it. An improved version of the script above would only rewrite the urls that contained your site's main domain. That way, users posting links to other sites would see those links leave the mobile app. But all internal links would remain within the app. (sort of what primelinks does for a standard phpbb site. but this would be specific to a webapp.]
Mobile forum or bust...