This plugin allows you to add an XHTML and CSS Halo 2 Stats sig to your WordPress blog, which you can then style to fit your layout. The plugin displays your emblem, your level in each of the ranked game types, and your overall rank, which is equal to the highest ranked gametype. If Bungie calculates this differently, I can’t tell. It also displays the total number of games played and the date and time of your last game. By default, the plugin uses the background from your profile page at Bungie.net: http://www.bungie.net/Account/Profile.aspx?player=ardamis. You can change this in your profile preferences.
It’s a pretty neat set up already, but the best part is that because it’s all XHTML and CSS, it is completely customizable. Change the font or the colors, move the elements around, even hide some of them, whatever, to suit your site. If you’re comfortable with PHP, you can even edit the plugin to display more or less information. I’ve written a brief explanation about how the plugin grabs the data in the post at Xbox 360 Gamercard WordPress Plugin.
The download includes:
- halo2stats.php (put this in your /plugins/ directory)
- halo2stats.css (copy and paste the contents into your theme’s style.css)
The plugin attempts to create a text file (halo2_cache_YOURTAG.txt) for use as a cache in your blog’s root folder automatically. Some server configurations may not permit the plugin to create this file and you’ll see resultant errors; in this case, you may have to manually create a file with that name and upload it to your blog’s root (and perhaps set permissions).
The plugin accepts two arguments: your gamertag and ‘nolinks’, a parameter to hide links to this page, the detailed game stats from Bungie.net, and the recent games RSS feed.
Insert the code:
<?php if (function_exists('ardamis_halo2')) ardamis_halo2('YOURTAG'); ?>
into a template file wherever you want the sig to appear, replacing YOURTAG with your actual Xbox Live gamertag, ex.:
<?php if (function_exists('ardamis_halo2')) ardamis_halo2('ardamis'); ?>
If you don’t want to display the various off-site links, add the ‘nolinks’ argument:
<?php if (function_exists('ardamis_halo2')) ardamis_halo2('YOURTAG',nolinks); ?>
The data we are interested in is served as HTML, not RSS. Incorporating an RSS feed into a page is pretty simple. Bungie does offer an RSS feed of recent game stats, but the feed is missing some crucial player stats, such as overall rank, rank by game type, games played and won per game type, and percentage experience needed for the next rank. All of this information, except the overall ranking, is available on Bungie’s player stats page. I don’t need all of this data, but I would like to be able to see my overall ranking. Unfortunately (there always seems to be an unfortunately), the Bungie player stats page doesn’t always provide accurate and complete information (you’ll often see an incorrect “No Games Played” message in place of your rank for a specific game type), and each change Bungie makes to that page has the potential to break the plugin. This is because the regular expression matching method I use to extract it expects to see specific lines of HTML code in the page. Should the layout change, the plugin might not find what it’s looking for, and so the whole system is both unreliable and fragile. For example, the plugin would have broken when Bungie changed the site around to add a section for Halo 3 stats, and it broke when the stats were reset and the new maps added on May 10, 2007. I’ll try to maintain this thing and quickly update it if/when Bungie’s changes break it, but I’m making no promises about future performance or usability.
The plugin takes the ranking for each game type and then sorts through them to find the highest one. The highest individual game type ranking is displayed as the player’s overall ranking. If Bungie has a more sophisticated method of determining overall rank, I’m not aware of it. But because of the occasional “No Games Played” message, the overall ranking might be incorrect.
Get the files here: (Current version: 1.4 beta)
Can I get this as a WordPress Widget?
Honestly, the plugin is much more flexible than a widget. Widgets are limited to your sidebar, while the plugin can be used in any template. Furthermore, this thing is 420 pixels wide, is that going to fit in your sidebar? Maybe some day when I have nothing else coming down the pike I’ll modify my plugins to be used as widgets, but not today.
How can I add the stats to a post?
Thanks to a really neat plugin, The Execution of All Things, you can call functions from any activated plugin from within a post. Once you have both the Halo 2 stats plugin and the wp-exec plugin installed, you can include the sig in a post with the line:
<exec type="function" name="ardamis_halo2" params="YOURTAG" />
How can I add the stats to a non-WordPress site?
I’ve been asked a few times for a way to get the same functionality outside of WordPress. I’ve put together a PHP script that you can include from any page with the line:
<?php include 'FULL-PATH-TO-SCRIPT/halo2stats-standalone.php?h2tag=YOURTAG'; ?>
Obviously, you’ll replace ‘YOURTAG’ with your gamertag. If you have spaces in your gamertag, replace each space with
I’m getting an error message
If your server does not have cURL enabled, you’ll get an error message that reads something like
Fatal error: Call to undefined function curl_init() in PATHwp-contentpluginshalo2stats.php on line 64. The best solution is to ask your host to recompile PHP with cURL. If that option is unavailable, I’ve provided an alternative plugin that uses the function file_get_contents(), but a number of hosts have disabled the URL retrieving capabilities in file_get_contents() for security reasons. Download the FGC Halo 2 Stats WordPress Plugin only if you are getting an error message with the regular download.
If you are trying to use the stand-alone script, but getting an error message similar to
Warning: include(halo2stats-standalone.php?h2tag=YOURTAG) [function.include]: failed to open stream: Invalid argument in PATH, you are not using the full URL in the path to the stand-alone script. You must use the full URL in your include whenever you use variables in the URL. Otherwise, the server looks for a file named halo2stats-standalone.php?h2tag=YOURTAG instead of executing the file halo2stats-standalone.php with the variable ?h2tag=YOURTAG.