Oliver Davies

Freelance Drupal Developer

Drupal Planet

Create Multigroups in Drupal 7 using Field Collections

28/08/2011 -- Oliver Davies

One of my favourite things lately in Drupal 6 has been CCK 3, and more specifically, the Content Multigroups sub-module. Basically this allows you to create a fieldset of various CCK fields, and then repeat that multiple times. For example, I use it on this site whist creating invoices for clients. I have a fieldset called 'Line Item', containing 'Description', 'Quantity' and 'Price' fields. With a standard fieldset, I could only have one instance of each field - however, using a multigroup, I can create multiple groups of line items which I then use within the invoice.

Display the Number of Facebook fans in PHP

15/03/2011 -- Oliver Davies

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.

Theme Custom Pagers in Drupal 6

06/01/2011 -- Oliver Davies

As part of my site's new theme, I decided that I wanted to have a Next and Previous link on the bottom of each of my Blog posts - like how Mark Boulton does on his Blog. So, I downloaded and installed the Custom Pagers module. I added a new custom pager using the 'Blog post' content type, and the blog view that I had already created previously. This worked, but I only had a very simple pager - ideally, I wanted to see the title of each relevant Blog post.

Optimise your Drupal Theme for an iPhone or iPod

30/11/2010 -- Oliver Davies

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.

The Inaugural Meetup for the South Wales Drupal User Group

27/09/2010 -- Oliver Davies

If you do Drupal, and you're in the area, come and join us for the first South Wales Drupal User Group Meetup!

We'll be meeting in the communal area just outside of the SubHub HQ, at:

4, The Studios

3 Burt Street
Cardiff

CF10 5FZ

For more information and to signup, visit http://groups.drupal.org/node/95104.

How to Create and Apply Patches

10/09/2010 -- Oliver Davies

Earlier this year, I posted a solution to an issue on the Drupal.org issue queue. Originally, I just posted the code back onto the issue, but have now created a patch that can easily be applied to any Drupal 6 installation. Here is a run-through of the process of creating and applying a patch. In this case, I made changes to the user_pass_validate function that's found within /modules/user/user.pages.inc.

Pages

Subscribe to RSS - Drupal Planet