Notes from Design4Drupal 2010: Stump the Experts FAQ


This is a talk moderated by Dmitri Gaskin, a 14 year old, freshman in high school. He's been doing Drupal for 4 years.

This is a Q&A session, and so go ahead and ask your questions, and either I or somebody else in the room should hopefully answer them.

Q: Apostrophes. Apparently automatic title generation interferes with apostrophes in title names. If I add an apostrophe, it doesn't appear in the database; the custom content will appear in the DB.

A: Could have to do with MySQL; you can insert custom PHP code, take the title, rewrite it and return the value with the apostrophe escaped out.

Q: I'm getting familiar with preprocess functions, but I want to add something my preprocess function is doing in the middle of the content variable, for example between two CCK fields in the content. I can append it to the content, but not between the CCK fields.

A: You can print out the CCK fields individually, instead of the CCK fields seperately. You can print the fields using $field_[fieldname]. If you don't want to do that, you can write code that inserts it into the content using a regular expression. Or, you can build a preprocess function that calls the fields and builds a variable, for example $modified_content, and use $modified_content instead of $content depending on when you want that function called.

Q: I have an auto node title issue as well, where I need to do a bulk update of node titles, probably a couple thousand nodes. I know views has a bulk operations, should I use that?

A: Just write a simple PHP script that finds all the nodes, loads them with the node_load() function, and then call node_save() on that same node. That will change the titles using your new automatic path variables. Another option is to use drush and run directly from the command line.

Q: I have two content types that have similar fields, that are rendered differently. They're both HTML textareas, but instances of one are rendered nicely, and instances of the other are rendered ignoring the formatting.

A: Do you have better formats installed? Try installing it, to give you more control over the input formats. Also check each field to make sure the settings are exactly the same.

Q: Lots of tools deal with the display of information in Drupal, but if I need to make a change to the Admin interface, there's not many tools other than form_hook_alter(). We want to limit selections from taxonomies, for example to be able to only see top level taxonomy terms, and have the child terms accordion out below.

A: There are one or two modules, heierarchical select, and another one, perhaps vocabulary index, which is a graphical module that lets users navigate taxonomy terms. In general, there aren't many generic tools for modifying administrative pages because each site has very specific needs that don't lend themselves to general modules.

Q: Importing our own taxonomy terms into Drupal, some taxonomy terms have both hyphens and spaces. I wanted to set views to accept these terms as an argument, and I'll set views to use a hyphen instead of a space, but if the term has hyphens and spaces, views will strip out the hyphens and then replace them with spaces.

A: You can use underscores, but you might end up with some terms that have underscores, and then you'll be back in the same boat. You could use spaces in the page title. You could also use the taxonomy term ID instead of the term title, but that isn't as human-readable.

Q: I'm curious of how Drupal handles parent/child relationships with content.

A: The standard way to use it would be to use nodereference fields using cck; put that field on the child, and the child will be able to select its parent.

Q: Can you cascade updates that way?

A: The nodereference field only stores the relationship, nothing about the node itself. You can use the node heierarchy module, which might work. Ultimately, you may find that taxonomy and views will work fine for you, with custom PHP scripts to pull the data out. Or, you can use the node auto taxonomy module to associate certain content with a taxonomy term, and then assign any node to that taxonomy term. Some of this is in Drupal 7 core.

Q: When I'm working with node templates, I get tripped up when I have to use $vars[...] or $node->... Is there some kind of key to know when to use which context?

A: In the preprocess function you always use $vars, because those get sent to the template file. If you want to use $node that's fine, but just know any modifications you make will not get sent to your template file.

Q: I have a question about configuring relationships in views. What does relationship do, and what does it allow?

A: Relationships allow you to go from one object to another. For example, a node is related to its author, any attached fields, and any nodereference fields that are on it. So relationships in views allow you to use the relationship of node/author to get the author's full name from their profile, and incorporate it into the view.

Add your relationship first, and then when you're adding fields, you get more choices.

Q: I've had a problem pushing code live in concert with database changes, etc. Does Drupal 7 help here?

Overheard: Oh please no, oh no not this question.

A: Not really. I tend to use the features module. I put all my content types into a feature, and then you can export that feature from one site and import into another site, for example. It still won't get everything. You can also use a versioning system like CVS, and backup/migrate a file copy of the database, and store that in the versioning system. However, this could overwrite content that has changed in the interim, while you were developing.

At Chapter Three, they do it site-to-site and use features, which is a best practice that turns all your feature changes into code changes, that you can check into version control. It dumps your config changes out into a file in a manner similar to the way you export views and panels. You basically end up with a module, except it is bigger because it contains all these configurations. However some pieces are missing, for example Taxonomy.

Q: When should I give up?

A: 1am.

Thanks to Dmitri for moderating this discussion, and providing concise, helpful answers to many questions. For more about his projects, check out Dmitri's user page at

Did you enjoy this post? Please spread the word.