Simple Code Tricks

How to Detect iPhone and Redirect to iPhone Version Website

Wednesday, December 9th, 2009

I came across a useful snippet of code that I wanted to pass on and post about. It detects whether the person viewing your website is on a iPhone or computer. If they are on a iPhone, you can redirect them to a iPhone version website or just to another page, its up to you. If they are on the computer it doesn’t redirect them and they go on as normal. Its just some simple javascript, and if you want to use it just change the “document.location” value to the url you want them redirected.

1
2
3
4
5
<script type="text/javascript">// <![CDATA[
	if ((navigator.userAgent.indexOf('/iPhone/i') != -1) || (navigator.userAgent.indexOf('/iPod/i') != -1)) {
		document.location = "http://www.scottrockers.com/iphone.html";
	}
// ]]></script>

Cya

New Envato Marketplace API

Wednesday, April 22nd, 2009

The Envato Marketplace, which includes sites like FlashDen and ThemeForest, has just come out with their own API. This API is an  interface which will allow developers to build applications and software that can easily utilize Envato user and item data. This allows me to get information in either XML 0r JSON.  So like my integration with WordPress and Flash, I could make a flash application that displays my sellable items from Envato Marketplace onto my Blog.  Its pretty cool.  Here is an example:

With this link,  it shows the xml created from the API of the newest files I have uploaded to GraphicRiver.net up to 10 (I only have one up so its only showing that one).

Here is the Envato Marketplace API Documentation.

Here is an API example. After clicking the link, look toward the bottom of the side navigation, I have some of my sellable items from the marketplace listed using the API.

Here is the code I inserted into the sidebar.php file in my wordpress files. I added it right after the last ‘<?php endif; ?>’. Don’t forget for it to work you have to download the Envato Recent Files Plugin, upload that to your plugins folder, and activate it.

<h2>Latest Sellable Items</h2>
	<li><?php echo envato_recent_items('your_marketplace_username', 'envato_sitename', 1, true, $ref='your_marketplace_username'); ?></li>
	<li><?php echo envato_recent_items('scottrockers', 'graphicriver', 1, true, $ref='scottrockers'); ?></li>

Cya

Table Border Colors not Displaying Correctly in Firefox

Tuesday, November 18th, 2008

There has been an issue with table border colors in Firefox not displaying correctly for a little while now.  The problem is that it is not showing the correct color, or it is showing a black line in the top and left sides of the cells of the table. There has been a work around created for it.  Just add this line of code into your css and it should fix the problem,

table, table td {
     border: solid 1px #eaeaea;
     /* or whatever color you want, just add the hexadecimal number */
}

Cya