PHP, Web development, Skiffle…

Site Build: www.jtccarpentryandconstruction.co.uk

The Link

The project

I was approached by John (the Chippy!) of JTC Carpentry & Construction for a minimal website that would cement his online presence a little, to work alongside his Trust-a-trader profile and facebook pages.

John came up with the logo himself, from which the concept for the site design wasn’t too much of a giant leap.

Quite specifically after a minimal site design, all John wanted was the a page with some information about his company (that he could edit himself), a contact form and a gallery area, to which he could upload images with captions.

The Geek Stuff

The site has been built using WordPress as a content management system (CMS), and my own WP configuration which will allow John to expand the site at a later date should he decide it is appropriate, and I’ve also made use of JQuery and a bunch of plugins, more details on those later…

I’ve based the WP theme around HTML5, but had to buckle a little bit to get the lightbox effect to work correctly, although with a little more attention I think this will run fine with the new HTML 5 block level element as opposed to the generic <div> containers. I’ve also implemented a little bit of PHP based browser sniffing to leave the Javascript off mobile devices, as the MopBox didn’t seem to translate so well to the smaller screen. That’s one for the to-do list right there.

Safe.

Germany government warns against Internet Explorer

You may have seen these stories in the news recently, relating to some attacks on Google, the German Government and Internewt Explorer.

The original news item
The subsequent reaction

I’ve tried as hard as I can to come up with something useful to say on the subject, but the only thing I keep coming up with is ‘use Firefox’.

So here we have it. Use Firefox.

Picking All The Big Ones Out

This is an old video, but one that I haven’t yet shared on here. It’s my kind of folk music, and this version of it is played on the following instruments:

  • Acoustic Guitar
  • Flying V Ukulele
  • 5-string Banjo
  • Tea Chest Bass
  • Gravy Granule Shaker
  • Novelty Miniature Bongo

Being a new parent I rarely get the ‘alone time’ to make more vids like this, but keep your fingers crossed -- one day my son might get off his 5-month old arse and look after himself, in which case the first on my list is ‘freestyler’ by the Bomfunk MCs

Safe.

Finding the RSS Feeds of your Facebook Status Updates

Edit:As of recent changes (7/2/2010) to FB, this is no longer working for me. You might have better luck. Why don’t facebook just make this stuff available?

Edit: This method has worked for my account and several others, but fails for some people. If you are greeted with the message “This feed URL is no longer valid. Visit this page to find the new URL, if you have access, http://www.facebook.com/minifeed.php?status&id=XXXXXX” or something similar then you are one of those unfortunate people. Currently looking into a solution for this problem… anyone found it?

I’m working on a ‘lifestream’ plugin for the next version of my website, and hit a little bit of a wall when trying to lay my grubby little paws on an RSS feed of my personal status updates on Facebook.

Although they don’t seem to publicise it on the site, there appear to be RSS feeds available by direct access of almost everything we post. It’s pretty obvious really. The only issue is finding the URL of the feeds.

For a personal page

The simplest way to do this that worked for me (although browsing around there appear to be some people experiencing difficulty) was as follows:

  1. Open up your notifications pop-up in the bottom right of your facebook window and choose ‘view all’
  2. Copy the link location of the ‘Subscribe to Notification > Via RSS’ option on the right of the page (something like – ‘http://www.facebook.com/feeds/notifications.php?id=123456789&viewer=1234567898&key=98765432a&format=rss20′
  3. Change it from http://www.facebook.com/feeds/notifications.php?id=123456789&viewer=1234567898&key=98765432a&format=rss20 to http://www.facebook.com/feeds/status.php?id=123456789&viewer=1234567898&key=98765432a&format=rss20 and paste into any RSS reader
  4. Check you privacy settings – The feed will only display status updates that are marked as being viewable by ‘Everyone’. ‘Friends Only’ status updates will not appear in the Feed. You can set this in your privacy settings, but also on each individual update as you post it.

There are other feeds accessible in a similar manner to this, but for my purposes I’ll not confuse the issue.

For a fan page

MUCH simpler:

  1. Paste the RSS url http://www.facebook.com/feeds/page.php?format=rss20&id=xxxxxxxxx (where ‘id=’  the ID of your facebook fan page – found in the address bar when you view your page) into any RSS reader
  2. If you’ve already set up your own vanity URL for your page, you can grab your page ID by logging in and clicking ‘Edit Page’. You’l find it tagged on to the url in the address bar.

And there you have it. From researching this, it appears Facebook have a habit of relocating the RSS Feeds without telling anyone – probably why they don’t publicise them too heavily – so you might find that these stop working in the future, but for now I’m all good to go in my project and hope I’ve helped you with yours.

Cheers,

Neil

Limiting the number of times a PHP loop will run using the break command

If you’re reading this page then you’re already likely familiar with the standard PHP for, while and foreach loops. If not, then may I suggest some background reading first – http://www.php.net/manual/en/language.control-structures.php.

That said, I added a new weapon to my PHP arsenal today in the form of a better understanding of the break command.

I’ve used the break command before of course – it sits inside switch statements to stop each case running into the next one as below:

  1. switch ($i) {
  2.     case "apple":
  3.         echo "i is apple";
  4.         break;
  5.     case "bar":
  6.         echo "i is bar";
  7.         break;
  8.     case "cake":
  9.         echo "i is cake";
  10.         break;
  11. }

But I didn’t realise that it can be used within any loop to stop the cycle continuing there and then.

This came in handy today when needing to perform a particular loop 8 times only. Normally one would just use a for loop, as that is what they’re -um- ‘for’, but in this instance I wanted to iterate across an array 8 times only. In essence, I wanted a foreach loop to run 8 times and then stop, regardless of how many items it contained.

Usually I would have either used array_slice() to reduce the array to 8 elements only, or introduced a counter and an if statement to my foreach loop as follows:

  1. $i = 0;
  2. foreach($array as $value){
  3.       if($i < 8){
  4.             echo $value;
  5.       }
  6.       $i++;
  7. }

Whilst this would work, it’s not an ideal solution because the foreach statement needs to perform the logical test ‘if $i < 8' for every item in the array - of which there could potentially be thousands. Which is where break comes in. Changing my foreach loop to the following…

  1. $i = 0;
  2. foreach($array as $value){
  3.       if(++$i == 8) break; //edit suggested by CHris
  4.       echo $value;
  5. }

means that as soon as the loop hits the ninth iteration (when $i is equal to 8) the break command is executed and the loop stops. No unnecessary iterations, and in my opinion much tidier code – which is always a good thing in my book!

This widget requires javascript and flash to be installed
copy following tag: