Drupal

Lets assume that you have a bunch of nodes for a content type and you want to tag them all with the same taxonomy term. First, find the term ID of the relevant term. In example, the term ID is 103 and the content type is "contact".

This is an example if an insert ... select statement.

Using .htaccess is one of the best ways to redirect a URL to a new URL. Particular care needs to be taken with Drupal sites for it to work correctly.

Drupal link function

The Drupal link function is a handy and easy way to create hyperlinks in your module or theme.

Find the number of results in a view. Add this snippet to the header or footer of the view, depending on where you want the number of results to be displayed.

Drupal Taxonomy vs Content Type Field

Drupal ships with an incredibly powerful and flexible categorisation system, called Taxonomy. However, many developers and site builders get confused when trying to decide if something should be a taxonomy term or a field in its own right.

You can use node relativity to attach nodes to other nodes. In this case, I am using it to attach reviews to product nodes, where the reviews are nodes in their own right. I want to be able to view the reviews (children) within the product node (parent).

If you have a live site and a stage (or dev) site, you will probably want to add any new files (such as images) from the files directory on the live site to the staging site, or vice versa.

This snippet will select Webform (Webform module) submitted data between a given date range. In this case, that date range is between 2009-06-04 and 2009-07-07.

The UNIX_TIMESTAMP function converts the date into a Unix Timestamp. This is because the value of submitted is in Unix Timestamp format.

It is often useful to add a "edit this node" or "edit this block" if a site editor is viewing content on a page that is not the node page itself. This includings viewing content from a "view" page where the normal edit tabs are not present for nodes or blocks.

Drupal for Publishers notes

This week I attended the Drupal for Publishers event that was held at the Sun Microsystems office in central London. As the name suggests, the event was aimed squarely at publishers. I work for the UK's biggest magazine publisher, so I thought I should attend! I was not disappointed.