Submitted by group42prime on January 8, 2013 - 12:25pm
New versions of websites often have new content organizations with new URL patterns. When old content is assigned a new URL it's almost always desirable to redirect traffic from the content's old URL to its new URL. The redirect preserves external links to the site content (i.e., prevents "link rot") and helps maintain search engine page ranking.
Submitted by Dale on December 28, 2012 - 11:10pm
The Drupal 7 Redirect module gives a site the ability to redirect from one URL to another using a proper HTTP redirect status (e.g., 301 - Permanently moved). In addition to the user interface there is a programmatic method for entering redirects.
The aptly named redirect_save function takes an object containing the details of the redirect and creates a redirect for the URL.
Submitted by Dale on March 17, 2012 - 8:47pm
Like many web types I have a number of small websites I look after, and I've never been happy with my backup solution. Until today.
My requirements are simple, create a backup of the database and files and save it on a local backup drive. The sites don't warrant anything fancy (like a cloud based solution that costs money). The procedure until now involved multiple, fussy steps. It turned out a single script solution is simple once a few key technologies are in place.
Submitted by Dale on July 11, 2011 - 9:56pm
A Drupal upgrade between major versions rarely means doing the upgrade procedure once. A new configuration, changing content, or needing to test different module versions typically means redoing the upgrade from scratch a number of times, a tedious, error-prone and time consuming process. Fortunately there's a solution: automation!
Scripting was always possible, but Drush has made it so much simpler. What follows is a review of the Drush commands I used via script to upgrade my Group 42 website to Drupal 7. The hand full of shell commands are basic and covered many other places on the net. The full upgrade scripts are at the end of the post.
If you're familiar with Drush I recommend jumping directly to the scripts.
Submitted by Dale on July 3, 2011 - 8:59pm
Replacing files during a Drupal upgrade can be tedious, especially for those of us who have to worry about SVN files in every directory. The following script automates this part of the Drupal upgrade, making it much faster and less error prone. I've been using the script in its current form for almost a year and it has served me well. And though most of my other bash scripts have been replaced by Drush commands, this script has proven better suited to my workflow than its Drush equivalent.
The script does the following:
- Deletes the current Drupal distribution files while preserving:
- SVN files
- all files in the /sites directory tree
- all files in /files directory tree
(I have a number of sites using the old file directory location)
- the Komodo (.kpf) project file
- Downloads and expands the Drupal distribution tarball if it has not already been done
- Copies the new Drupal distribution files to the target directory
- Removes the unrequired text files. e.g., CHANGELOG.txt, INSTALL.mysql.txt
Submitted by Dale on August 31, 2010 - 7:52pm
The steps for programmatically creating a node are:
- Create a PHP object representing the node data
- Save the object using the node_save() function
While the mechanics are simple, there is an important responsibility involved. The Drupal work flow does data validation before calling the node_save() function; node_save() does no validation. By calling node_save() directly your code takes the responsibility for providing valid data.
Drupal 7 Changes
A quick note for those of you familiar with Drupal 6. You'll notice two changes in Drupal 7:
Body Field Is No Longer Special
In Drupal 6 the body field was special. Specifically, it had a different data structure than other fields and it always existed, even if it wasn't used. With Drupal 7 the body field is a standard field provided by core and is truly optional.
Language specification is required for the node and some fields.
The format of the text field filter is now specified by machine name, not integer. For example: full_html, filtered_html, or plain_text. This is great news for moving contents between different Drupal systems.
Basic Node Creation
The following code assumes an unchanged Drupal 7 Standard installation and will create a Drupal 7 article node.
Submitted by Dale on August 17, 2010 - 1:14pm
Blocks in Drupal 6 (and 5) always felt a little less loved than other portions of Drupal. While the node and theming APIs offered straightforward and often elegant methods to modify behaviour without modifying other peoples' code, blocks weren't so fortunate. Lacking API support, working with blocks often meant writing ugly code. Last week helping with the Drupal Block API documentation I discovered this has changed in Drupal 7. I thought I'd share what I learned.
The information I'll discuss is a summary of the block information from:
Submitted by Dale on July 30, 2010 - 3:21pm
An example, like a picture, is worth 1000 words. Until recently Drupal programming examples existed but were spread among documentation pages, blog posts, and the Drupal CVS repository; some searching required. That changed in late 2009 with the introduction of the Examples for Developers module. Its purpose: "to provide high-quality, well-documented API examples for a broad range of Drupal core functionality". Now you can find high-quality, working Drupal 6 and 7 code examples in one place, many with SimpleTests.
Submitted by Dale on July 23, 2010 - 8:16am
Drupal's scripting abilities just keep getting better and better. Since publishing my Drupal Command Line Script Template last year I've moved exclusively to the Drush php-script (scr) command. The script template article still gets a lot of page views - perhaps because with all the functionality in Drush it's easy to miss the scripting feature - so posting an update seems like a good idea.
Drush Scripting Advantages/Disadvantages
The advantages of using Drush over using my original template are:
- Drush takes care of creating the Drupal environment for the script to run in, which is the only function the template served. Using Drush factors out the environment common code, eliminating redundant code in individual scripts.
- Drush makes it easy to place the script files in a directory outside of the Drupal website home directory. Placing script files outside the website home directory eliminates a whole range of security issues.
- The Drush code that creates the Drupal environment is reviewed by the community, making it far more robust than something a single person could create or maintain on their own.
- When the code required to create the Drupal environment changes you don't need to update individual templates, just Drush.
Submitted by Dale on July 8, 2010 - 2:05pm
In May I attended Melting Silos Case Study – Riese: From Bytes to Broadcast, a talk in the What’s Going On Salon series. From the talk description:
Join Riese series creators Kaleena Kiff and Ryan Copple as they share their combined learned experiences in navigating the constantly shifting landscape of new media in taking their Vancouver based web series production mainstream. Among their unique insights are models of remaining adaptable as the landscape shifts, strategies for harnessing a fan base and planning ahead for the jump to mainstream media. They will showcase their multiplatform property including examples of their ARG and their iPhone game app.
Kaleena Kiff is no stranger to television production. She worked as a child actor in California and after getting her BA from McGill moved behind the camera (though she does have bit-part credits on Supernatural and Smallville). Ryan Copple graduated with a Masters of Forensic Psychology in Nebraska then moved to Vancouver to pursue a film career. Their presentation was a rapid fire staccato of detail organized into topic areas. Unlike so many presentations, the detail was imbued with their personality and experience, making for both an entertaining and informative session.
Kiff started by pointing out these are still early days for Riese. Though progress is excellent, the presentation was framed as success to date, not the final summary. Here, with no specific narrative, are my notes from the presentation: