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.

See Tag nodes from a content type with a taxonomy term Snippet

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.

The following snippets needs to be added to the root .htaccess file directly after the following lines:

# Various rewrite rules.

RewriteEngine on
.......

See Drupal redirect in .htaccess Snippet

Drupal link function

Blog Post

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

Read Drupal link function

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.

From: http://drupal.org/node/131031

See Number of results in a Drupal View Snippet

Drupal Taxonomy vs Content Type Field

Blog Post

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.

Read Drupal Taxonomy vs Content Type Field

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).

See Node relativity view childen in parent node Snippet

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.

Run this rsync command, assuming you have navigated to the root Drupal directory (such as public_html). This also assumes that your stage site is located in the stage directory.

See rsync Drupal files directory for staging site Snippet

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.

See Select Webform submissions between a date range Snippet

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.

See Add Edit this node/block link to Drupal View Snippet

Drupal for Publishers notes

Blog Post

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.

Read Drupal for Publishers notes
Syndicate content