Tutorials

Rebuild your node_comment_statistics table

Published September 29, 2008

If you're like me, most of your projects are redesigns of existing sites. And if the site is already on some kind of CMS, this means importing content from the old system into Drupal, and to make it easy you'll do it with MySQL directly. There are pros and cons about this approach, which I am learning, and one of the cons is that content created by the database may not always get plugged into all of Drupal's various tables. Sure, you got the text into node, node_revisions, can your CCK tables, but there is more than meets the eye.

Import Hundreds of Taxonomy Terms using AWK

Published September 16, 2008

Today's challenge: your editors just handed you almost 200 taxonomy terms to add to the site, and you don't have the time or inclination to hit the taxonomy/n/add/term page for the next 2 hours or so... AWK to the rescue! Doing a simple CSV export of the term_data and term_hierarchy tables, you've got a pretty simple structure: term_data tid,vid,name,description,weight term_hierarchy tid,parent What you'll ultimately generate here is a file that stores everything you need to know about importing these terms via a CSV - the term names, the weights, good IDs, and the TID of the parents. 2048,#the current value of the sequences for term_data term,34,Blogs,#a helper line x,1,Drupal,All about Drupal,-5 x,1,Modules,Ways to extend Drupal,-4 x,1,Themes,Making your install pretty,-3 term,35,News,#a second helper line x,1,International,,0 x,1,Local,,0 x,1,Hyperlocal,,0 In this file, we've got 3 types of data: The starting value for sequences The id of the parent term for the next several rows, starting with the word "term" followed by the TID and the plain English name just to help us get organized The new terms, with an "x" where the new TIDs will be placed, and the VID, Description and Weight all filled out.

Custom GMap Solution for Dynamically Updated Markers (Part 2)

Published August 27, 2008

In my previous post , I talked about how I implemented the dynamic marker system on OffRoadAtlas.com . In this post, I'll cover the functionality that the PdMarker adds to the site. When you first hit the home page of the site, you'll see that the main content area is separated into two main sections: the narrow column to the left of the map (I call this the "info column") and the map itself. The idea behind the info column is that as users click on markers on the map, instead of the standard GMap info window, a very brief

Custom GMap Solution for Dynamically Updated Markers (Part 1) (Drupal 6)

Published August 25, 2008

I recently upgraded OffRoadAtlas.com with a custom map interface based on the GMap module. I was able to do this while leaving the GMap module is virtually un-hacked (with the exception of modifying the "GMAP_API_VERSION" variable) - all of the customizations were made via an additional "helper" module that was written specifically for this site. The site utilizes a map on the home page that shows all the off-roading areas and clubs in the database. The problem I was trying to solve was that I didn't want to have to load all 1,500+ points each time the home page was

US States list for CCK select boxes

Published August 22, 2008

When defining Content Types in Drupal with the Content Construction Kit you are able to add select boxes to them with CCK. It takes its key/value pairs in this format: Key|Value . One of the most common tasks for this is to create a drop down list of US States. So to save folks some time, I have compiled a list for you to paste right into your own projects. The attached text file will give you US States in the expected format. Hopefully this will save others a bit of typing when you need such a list for your own Drupal projects. Enjoy!

Drupal Theming: $path vs. base_path and path_to_theme

Published August 20, 2008

When developing Drupal themes, there is one bit of code you type over and over again: sites/all/themes/blueprint/images/whatever.jpg Where images/whatever.jpg could be a css file, or other file, but is normally an image. However, since clean URLs in Drupal appear to make fake directories, the web browser thinks your image is located in: node/345/sites/all/themes/blueprint/images/whatever.jpg When it's not. Luckily Drupal has tools to help you in this case.

Using Views 2 and Drupal 6 to Create a Related Pages Block

Published June 17, 2008

Today's question comes from Dale at NFi Studios in Orlando, FL - my home town: Essentially:, what i'm trying to do is 1. Determine the current nodes taxonomy terms 2. Determine all other pages that share taxonomy terms 3. Display the title (and link) to those pages in a block Using Drupal 6.2 and Views - Looked at a few modules, but nothing quite exact - Reviewing some module snippets right now to see if I can potentially use an argument to do it.

Using AWK to Download and Unpack Drupal Modules

Published June 16, 2008

When installing a new Drupal site (or when your list of available updates gets nice and long), you'll often have to download tons of modules, unpack them, and copy all of the resulting directories to your sites/all/modules directory. Personally, I'm not a fan of all the clicking, downloading, unzipping and most of all waiting! Today I finally settled on a workflow that gets the job done, and it's called the UNIX command line. If your server doesn't use some flavor of UNIX or Linux, or if your web host doesn't allow you shell access, you may want to stop reading after the next paragraph.

Creating Modal "Please Wait..." Dialog Boxes with jqModal jQuery Plugin (Drupal 6)

Published February 24, 2008

Part of the power of having jQuery integrated with Drupal is the ability to take advantage of the strong jQuery developer community. There are many, many plug-ins for jQuery that can add some great functionality to your site - usually with very little code. jqModal is just one of these plug-ins. It can be used to create modal (or non-modal) dialog boxes. In this example, I'm going to show you how to use it to create a modal "Please Wait..." dialog box. This can be useful when your user submits a form that might take a few seconds to process

Editing HTML around Displayed View Fields: Views Theme Wizard

Published January 26, 2008

Question #2 also comes to us via our Facebook forum Modifying existing views. Michael Blake (Orlando, FL) wrote on Jan 24, 2008 at 12:08 PM. I'm working on an existing Drupal application that has a custom Content Type. This includes some custom fields. When I change a custom field, such as add markup before and after it, This does not appear in my views. I think it's because my Views have been exported. However if I change the .php files in the themes directory directly on the server, I get what I want. My question is , if I go about it this way, can someone else come along export a view and erase my changes? Or do I need to re-export every time I make a change? Thanks.

XML Sitemap not associated with pathauto url aliases

Published January 23, 2008

This question comes to us from our Facebook forum . It feels good to answer, because this is the first of many questions we'll be answering here on the site. Some Help I need (XML Sitemap) Omar Eduardo Fernández (MIT) wrote on Jan 8, 2008 at 5:52 PM. So right now, I've been trying to fix an issue I have on my website. I imported everything I had from WordPress (posts, comments, categories/tags, etc), and then I installed the pathauto and the XML Sitemap modules. The problem I'm having is that XML Sitemap is producing a sitemap with every link in terms of nodes rather than the aliases my pages now have, and I would strongly prefer it to use the aliases. My NEW content is being included in the sitemap using aliases, but all the previously imported content is in the node format. You can look at my sitemap if you're not sure what I mean, is http://omareduardo.com/sitemap.xml Thanks for any help! -Omar