Submitted by gareth on Fri, 11/06/2010 - 15:54
When you get older you need to write functions to help you though the day:
Submitted by gareth on Thu, 27/05/2010 - 20:31
I was recently asked to block users from signing up to a drupal site using a hotmail email address.
To achieve this I wrote a small module that will intercept the validate operation of the user module and add in an extra validation on the mail field of the user registration or edit form.
Create your dot info file: hotmail_check.info
; $Id$
name = Hotmail Check
description = "Removes the ability to login with a hotmail email address."
core = 6.x
Then create your dot module file: hotmail_check.module
Submitted by gareth on Fri, 16/04/2010 - 14:47
I wrote a little linux bash script that I get cron to run each night to create a backup of my drupal site. I may expand it later to include auto deletion of older files and database dumps, but for the meantime I will just manage the backup files manually.
Basically create a file and call it something like site_backup.sh
Submitted by gareth on Tue, 09/03/2010 - 11:59
The format
The drupal 6 link function takes the format of:
l($text, $path, $options = array())
This will format an internal Drupal link.
This function correctly handles aliased paths, and allows themes to highlight
links to the current page correctly, so all internal links output by modules
should be generated by this function if possible.
Parameters
$text - The text to be enclosed with the anchor tag.
$path - The Drupal path being linked to, such as "admin/content/node". Can be an external or internal URL.
Submitted by gareth on Wed, 17/02/2010 - 13:09
When programmatically creating a new content type I would like to set the default publishing options, comment settings and upload settings, as the content type is installed, so I create a dot install file for the content type with the following:
Submitted by gareth on Mon, 02/11/2009 - 22:42
In order to keep track of versions of your code, or just to keep a record of the changes you make to code, github.com is an alternative VCS to the popular SVN. Here are some steps to ensure your code is kept up to date, even if you are sharing your codebase with other developers.
Submitted by gareth on Mon, 26/10/2009 - 15:24
This is a script to run when using an SSH connection to move a MySQL database to another host.
mysqldump --host=<host_ip_address> --user <db_username> --password=<db_password> <database_name> > mysqldump.sql
mysql -u <db_username> -p <db_password> -h <host_ip_address> <database_name> < mysqldump.sql
In the first line you should replace the bits in brackets with the host database you need to backup and the second line should be the details of the host you are restoring to.
Submitted by gareth on Tue, 13/10/2009 - 15:38
I recently found that one of my applications no longer works when I install it. Bit of a bummer as you always discover this only when the it is urgently needed.
A lot of head scratching ensued, as the same code is working still working perfectly elsewhere. I checked the php versions and configs, checked the apache setups, all similar enough not to cause any problems. The only clue to what was going on was a mysql log file entry of:
Submitted by gareth on Mon, 05/10/2009 - 01:36
Submitted by gareth on Thu, 13/08/2009 - 22:42
The next file we will look at is the .module (read dot module) file is where we get down to the php. This file contains a number of functions that will do all the work in creating the content we require. Many of the functions we will use are actually hook functions that drupal calls at specific times during page rendering process.
Pages