I installed the IWPhone plugin from here. I haven’t tried to make the other content work in the plugin yet, just the Blog for now. Seems to be working just fine after some tweaks to my site-wide include files to special case the User-Agents. If you need to do something similar just add:
<?php
$container = $_SERVER['HTTP_USER_AGENT'];
$useragents = array (
“iPhone”,”iPod”);
$iphone = false;
foreach ( $useragents as $useragent ) {
if (eregi($useragent,$container)){
$iphone = true;
break;
}
}
if (!$iphone)
{ ?>
#insert conditional HTML here
<?php
} ?>
So for example, I have a site-wide header.php and footer.php that are not from wordpress. So I added this conditional to prevent my standard graphic header and footer from appearing on iPhones.
That reminds me, I don’t think I’ve mentioned exactly how I integrated WordPress into an existing site, without letting WordPress takeover the whole site. So, I had an existing site with a hand-rolled blog system I started back in school. I had the entire site using the same CSS, header, footer, and navigation bar. The hand-rolled blog got to be a little lacking in features and I didn’t have time to maintain it so decided to move to WordPress. A few minutes looking at the database and writing a Python script had my old database loaded into a WordPress schema.
The data was now ready, but I needed to address the hard part, the format and structure needed to be unified. I didn’t want to maintain a separate CSS/base includes for /* and wordpress/*. After a long, long time of looking through the wordpress code and a lot of trial and error I arrived at this as the key set of includes for a custom header in WordPress 2.2 (the commented out lines work in 2.0 IIRC):
<?php
include_once('./wordpress/wp-includes/script-loader.php');
include_once('./wordpress/wp-config.php'); include_once('./wordpress/wp-includes/wp-db.php');
# include_once('./wordpress/wp-includes/wp-l10n.php');# include_once('./wordpress/wp-includes/template-functions-general.php');
# include_once('./wordpress/wp-includes/template-loader.php');
# include_once('./wordpress/wp-includes/template-functions-post.php');
$templatePath = get_bloginfo("template_directory");
define('USE_NICETITLE', 0);
?>
After this I can compose a header file that uses WordPress functions, such as get_archives, but is still separate from my WordPress theme itself. If you look at the source to this page you’ll see a wrap div tag followed by a container div tag and finally a content div tag. I use these divs to place the formatting information in the appropriate place. For the highest level “wrap” tag it opens in the site-wide header and ends in the site-wide footer. The “container” and “content” tags open and close in their respective sub-pages. So for my school work those tags appear in school.php. For my blog content they appear in my theme files such as single.php or index.php.
At this point most of the hard-work was done, I just had to hack away at the theme to make the content validate (after all I had just completely broken the CSS and HTML validity). There were other things that had to be addressed as well, like the theme I used inside of wordpress had it’s own thoughts on a navigation bar, but that was the easy part ![]()
feed

No comment yet