WordPress Opengraph and Microdata Generation without a plugin
Its really useful to have Opengraph (Facebook) and Microdata (Twitter) information in your blog header.
The Facebook Opengraph and Schema.org microdata lets you optimize your blog much more better and helps search engines to index your website better to show rich snippet.
It also lets Facebook and Twitter users to share your blog with proper title, description, url and image.
There are loads of plugins available to do this, but why use a plugin when its only a few lines of code?
Neil Anthony Kitchens
Neil Anthony approached me in May of 2010, their brief was simple, create a site that reflected the class and high quality kitchens they designed and installed, make the site clear, crisp, informative, easy to navigate and most importnatly easy to update by the client. Iachieved all of these goals and the staff at NA who weren't particulalry PC literate regularly updat etheir site to reflect new product and special offers.
[Snippet] Setting the timezone for PHP 5.3
PHP 5.3 requires a time zone to be set if you do any kind of date processing.
Simply set this in your php.ini
Install the Remi Repo in CentOS
The Remi Repo is a yum repository maintained by a French dude - Remi Collet. It contains much more up to date packages (January 2012) such as MySQL 5.5 and PHP 5.3.
Heres how I installed it on CentOS.
Make an SEO friendly URL in PHP
Just like WordPress creates it's slugs or friendly URLs, I had to write some code to achieve the same for a customer running a custom web application.
Here's how I did it.
PHP Header Redirects
There's a few ways to redirect a page in PHP. Well, two. A right and a wrong.
Wrong Way
Right way
This is evident on IIS6 and IIS7 where the wrong redirect will just fail.
Even if you are not using IIS6 or IIS7 its good practice to set the headers correctly and exit the script.
Getting YouTube thumbnails for HTML
It's so simple to embed a YouTube video, with thumbnail into your site. Ditch any clever PHP scripts or completed jQuery libraries.
So you have a Youtube video - http://www.youtube.com/watch?v=t4_dZPVg8KI
Take the video ID t4_dZPVg8KI and craft yourself a link to YouTube's image server;
http://img.youtube.com/vi/t4_dZPVg8KI/1.jpg
You have a choice of 1.jpg or 2.jpg or 3.jpg
How easy is that!
[Snippet] Allow PHP in Smarty (CubeCart 5)
Although it is generally bad practise to put PHP code directly into your (CubeCart 5) Smarty templates, its sometimes inenvitable.
You will need to edit controllers/controller.index.inc.php
[Snippet] Formatting the date in twitter XML feed
The date in the Twitter XML feed is daft and ugly! It reads [created_at] => Wed Aug 03 23:34:35 +0000 2011
We can easily format this with PHP using date() and strtotime()
Using the Twitter XML Feed in PHP
Parsing the Twitter XML feed for a user in PHP is now super simple.
- $username = 'Kieran_Barnes';
- $format = 'xml';
- $tweet = simplexml_load_file("http://api.twitter.com/1/statuses/user_timeline/{$username}.{$format}");


