PHP

Display the Number of Facebook fans in PHP

Added on 15th March 2011

Replace the $page_id value with your Page ID number (unless you want to show the number of fans for this site).You can find your Page ID by logging into your Facebook account, going to 'Adverts and Pages', clicking 'Edit page', and looking at the URL.

For example, mine is https://www.facebook.com/pages/edit/?id=143394365692197&sk=basic.

I've also wrapped the output in a number_format() function so that it properly formatted with commas etc - like where I've used it within the Gold Event listing on the Horse & Country TV website.

Optimise your Drupal Theme for an iPhone or iPod

Added on 30th November 2010

To begin with, enter the following code at the top of your page.tpl.php file:

 

{syntaxhighlighter brush: php;fontsize: 100; first-line: 1; }<?php
if (ereg('iPhone',$_SERVER['HTTP_USER_AGENT'])) {
$iphone = 1;
} elseif (ereg('iPod',$_SERVER['HTTP_USER_AGENT'])) {
$iphone = 1;
} else {
$iphone = 0;
}
?>{/syntaxhighlighter}

This creates an 'iPhone' variable, and sets its value to 1 if the an iPhone is being used. The value of the variable can then be used in an 'if' statement to create content that's only shown if an iPhone is being used.

Create a Better Photo Gallery in Drupal - Part 2

Added on 17th August 2010

At the end of my last post, I'd finished creating the first part of the new photo gallery, but I wanted to change the dates of the published photos to reflect the ones on the client's original website.  

Firstly, I'll refer to the previous list of published galleries that I created before, and create something different that also displays the created and modified dates. Picking the node ID of the required gallery, I used the following SQL query to display a list of photos.

 

Subscribe to RSS - PHP