kieranbarnes Independent PHP, WordPress & CubeCart Programmer

WordPress Opengraph and Microdata Generation without a plugin

Posted on February 17, 2012

Posted by kieran

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

Posted on January 26, 2012

Posted by kieran

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

Posted on January 25, 2012

Posted by kieran

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

  1. // London, England, Europe
  2. date.timezone = "Europe/London"
  3. date.default_latitude = 51.500181
  4. date.default_longitude = -0.12619

Install the Remi Repo in CentOS

Posted on January 7, 2012

Posted by kieran

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

Posted on November 20, 2011

Posted by kieran

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.

Tagged as: , , , Continue reading

PHP Header Redirects

Posted on November 4, 2011

Posted by kieran

There's a few ways to redirect a page in PHP. Well, two. A right and a wrong.

Wrong Way

  1. header('Location: foo.php ');

Right way

  1. header('HTTP/1.0 302 Found');
  2. header('Location: foo.php ');

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.

Tagged as: , No Comments

Getting YouTube thumbnails for HTML

Posted on November 4, 2011

Posted by kieran

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!

Tagged as: , No Comments

[Snippet] Allow PHP in Smarty (CubeCart 5)

Posted on September 28, 2011

Posted by kieran

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

Posted on August 17, 2011

Posted by kieran

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()

  1. $latest_tweet_date = date("l M j \- g:ia",strtotime($tweet->status[0]->created_at));

 

Tagged as: , No Comments

Using the Twitter XML Feed in PHP

Posted on August 17, 2011

Posted by kieran

Parsing the Twitter XML feed for a user in PHP is now super simple.

  1. $username = 'Kieran_Barnes';
  2. $format = 'xml';
  3. $tweet = simplexml_load_file("http://api.twitter.com/1/statuses/user_timeline/{$username}.{$format}");
Tagged as: Continue reading
Page 1 of 41234