Archive for the ‘Web Development’ Category

How to test for any TextLinkAds first

Sunday, April 15th, 2012
Posted in Uncategorized, Web Development · Tags: , ,

If you run Text Link Ads with the WordPress plugin, you might run into a situation where you want to check to see if there are any ads before you output them on your site. The reason, maybe that you have some heading or decoration near them that depends on them showing up. Well, I made a little hack to do just that.


<?php
/*homepage only*/
if(is_front_page() && function_exists("tla_ads"))
{
//hack to see if we have any ads available
global $textlinkads_object;
if (count($textlinkads_object->ads) > 0)
{
//output whatever heading or decoration you want here
tla_ads();//show ads
}
}
?>

Stop using 960 pixel width web designs for no reason

Friday, March 4th, 2011
Posted in Web, Web Development

Something that’s been a pet peeve with me, is that too many sites use 960 pixels, no matter how much content a site has. I understand it works great for at 1024 width resolution and there is nothing wrong with white space. But I’ve seen too many sites use it with no thought. Often times you see a site and there is only a paragraph or 2 in the left and 1 in the right and the design doesn’t utilize the whitespace and lack of information on the page. Does this mean use 760px (good for 800 width resolution)? Personally I think if you want your site to stand out a bit, you should use a smaller size width or a different width size than those 2 standards, but again it depends on how much content you have and how your design handles varying amounts of content.

Now about centering pages, I know resolution widths these days can be huge on wide screen monitors; However if you want to set your site apart a little, place it slightly off center. Depending how off center you place it, you may want to balance it off with a subtle background graphic or something on the other side or slightly on the opposite side. I’ve done this on a few sites and it really seems to make the site seem fresh, compared to the 960px landscape. But perhaps you know of the 960 grid system CSS framework and think its the only way to design.

Calculating the Moon Phase Part 2

Monday, January 4th, 2010
Posted in Web Development · Tags: ,

In an older post about Calculating the Moon Phase, I converted the some code I found to PHP. However the Lunar Phase Calculator has some more information (ecliptic latitude and longitude in degrees, the moon’s distance in Earth radii, etc.), the other one doesn’t, so I went ahead and converted it from JavaScript to PHP.
(more…)

RSS Cron Job

Monday, December 14th, 2009
Posted in Web Development · Tags: ,

If you are on shared web host, you might not have the ability to run lots of cron jobs or be limited to a certain number per hour or day. You might know about the “Poor Man’s Cron Job”, which is basically not to run a task (usually caching some data or fetching a feed, api, etc.) in the background until someone visits a page. Which isn’t ideal, because often the page will be slow or sometimes it won’t be up to date until the second visit (if you run that task after outputting the cached data).

Well one way to get around this is to setup an RSS feed for the data you are caching or outputting and access it with a query string such as “?rss=2.0″ or http://example.com/index.php?rss=2.0. Then you can check to see if the RSS variable was passed and output a RSS feed with just enough data for a feed, no need to put sensitive data in there or anything. I would suggest putting in a ttl node in the RSS feed and set it to something the aggregators like Google Reader, should obey (that way they hit your page more or less frequently, depending on your needs). The item portion of an RSS feed only needs a title or a description, although its probably a good idea to put some kind of guid in there (check the RSS 2.0 spec for more info on creating RSS feeds).

Anyway here is some sample code. It isn’t complete but gives you an idea what I mean.

if ($_GET['rss'] == 2.0)
{
//create RSS 2.0 feed
header('Content-Type: text/xml');
$output = '<' . '?xml version="1.0"?' . '>' . "\n";
$output .= '<rss version="2.0">' . "\n";
$output .= '<channel>' . "\n";
//...
//process your data and output it into RSS 2.0 format
//...
$output .= '</channel>' . "\n";
$output .= '</rss>';
}
else
{
//process your data as normal
}

Then to make sure the page is hit often, place your RSS feed into Google Reader or Bloglines or some other RSS aggregator. Then your site will be visited often and forced to update. No one else really needs to know about your RSS feeds, unless you want them to be public as well.

CSS3 Validation Debate Reponse

Tuesday, September 1st, 2009
Posted in Web Development · Tags:

There is a post on CSS3.info, The Big CSS3 Validation Debate where I left a comment I figured I’d make into a post here. It’s about how adding CSS3 rules to your style sheet result in errors with validation and what we think the W3C should do about it. Anyway, my response is below (edited, because I pressed submit too soon). :P


No need to have the W3C mess with their validator just to work with all the possible browser extensions. This would most likely introduce bugs and cause too much of a headache for them.

Here are 2 things you can do to get by the errors

  1. Put all your CSS3 rules in a css3.css file and then when you validate everything in your regular .css files should pass and the css3.css should fail.
  2. Or put a /*CSS3*/ comment for each CSS3 rule you have in your style sheet, so when it gives an error you know why. This would work best if you put each css3 rule on a separate line.