Drupal Logo

Drupal Focus On Enterprise, London, 26 May 2010

31st May 2010 - 15 minutes read time
Drupal Focus On Enterprise 2010

2010 saw the third annual Drupal Focus on Enterprise conference, which took place at the Sun Microsystems offices in London. The free event, which is sponsored by Sun, brought together a set of speakers to talk about different things that they or their businesses have done with Drupal. Even though I live in Manchester I was lucky enough to go along.

The conference consisted of two tracks, with a number of talks in each. I obviously couldn't go to every talk, but the talks I did see were of a very professional standard. The tracks weren't set in designated rooms but a head count was made of everyone who wanted to see which track and the bigger room used for the talk that got more votes.

I also arranged to meet fellow North West Drupal User Group (NWDUG) member @eli_t at the conference.

Drupal Logo

Related Items Block Using Drupal 6 Search

23rd May 2010 - 10 minutes read time

A related items block looks at the current content of the page and tries to present the user with a list of items that relate to the current content. Creating a related items block is quite easy, and is a good way of introducing the search module api without having to get to involved in the search module.

Before starting I should point out that there are other related items modules available. These are modules like Related Nodes or Related Items but these modules either aren't released for Drupal 6, or simply don't work in the way I wanted the block to work. I wanted a module that would act with little or no user input.

WordPress Logo

Wordpress Dynamic Page Menu Navigation

19th May 2010 - 8 minutes read time

After writing the function that creates a list of pages that are children of a given page in Wordpress I needed something more robust and automatic. To that end I created a plugin that will create a widget that contains a dynamically created menu of pages.

The widget figures out what page is currently being displayed and will climb the page tree until it finds the root page. Whilst climbing the page tree the plugin will keep the path to the currently selected page and when the tree is printed out the path will be open. It is best suited for sites that have a solid hieratic page structure, rather than a simple blogging site.

In terms of efficiency I have tested it with pages nested up to 25 levels deep with only a small decrease in page load. However, for the average small Wordpress site this plugin is perfect as pages will only be nested a few levels deep.

Drupal Logo

Drupal 6: Change Title On Blog Index Page In Drupal

11th May 2010 - 4 minutes read time

The title tag on the Blog module index page (found at /blog after the module is installed) is by default "Blogs | Sitename", which isn't editable in the backend of Drupal. I've been talking to other Drupal developers and reading forums about the best way to go about changing the title of the blog index page. Ideas ranged from editing or duplicating the blog module (which is bad practice) to installing the String Overrides to provide a quick translation of the string in the title.

These suggestions are either quite poor, or simply overkill for what should be a simple string replacement. There were two methods we decided upon that work quite well and are easy to implement.

1) The first involves creating a page-blog.tpl.php template file and adding a str_replace() function call to replace the word blog from the title of the page. This would look something like this:

WordPress Logo

Get Child Pages List In Wordpress

10th May 2010 - 2 minutes read time

It is possible to print out a list of pages in Wordpress, but these functions are designed to print from the root pages to a certain level. I often need to print out a list of pages that are children of the current page being looked at so I created the following function.

Linux Logo

Running Commands In The Background In Linux

9th May 2010 - 2 minutes read time

A useful technique to know about when using Linux is to run commands in the background. Sometimes certain commands can either take a while (like copying a large file) or will simply take over the terminal window when run. For example, lets say that you open a file in gedit, you might use the following command.

gedit file.txt

Doing this will open the file in gedit but will not allow you to do anything in the terminal window until you close gedit. To open the file but still keep the terminal window active use the & symbol at the end of the command. This will run the proceeding command in the background.

gedit file.txt&

To run a file copy in the background do the following.

PHP Logo

Parsing XML with PHP

6th May 2010 - 11 minutes read time

XML data extraction can be a common task, but to work directly with this data you need to understand how PHP parses XML. There are various different functions involved in parsing XML in PHP, all of which work together to extract data from a XML document. I will go through each of these functions and tie them together at the end.

xml_parser_create()

This function is used to create the parser object that will be used by the rest of the process. This object is used to store data and configuration options and is passed to each of the functions involved.

WordPress Logo

Add Enctype To Wordpress Post And Page Forms

27th March 2010 - 2 minutes read time

Whilst creating a small plugin on a Wordpress site I decided not to use the media library as I just wanted to add some small stub images to the content. I created some boxes on the post page using add_meta_box() and added a file input box to them. The only thing is that the post form in Wordpress doesn't have the enctype="multipart/form-data" attribute and so it won't pass file to the $_FILES array in PHP.

It is not possible to add the enctype into the form declaration via Wordpress as there is no hook or action to do this. So the only alternative (rather than hack the source code) is to add the attribute using JavaScript, and as we have JQuery already loaded we can utilise that.