Blog Archive for April 2012
A Basic Drupal Module
My co-worker, Joe Tower, is a designer/developer who is just getting into coding his own Drupal modules. Over at his blog, earlier this weekend, he created a basic module. I thought it needed a couple more things, so I'm gonna pick up where he left off. You might learn a bit or two about how the innards of Drupal work if you keep reading.
First of all, I took his basic my_menu_module_form_content_type_form_alter() function and made it a bit more general. This version of the function, using the less specific hook_form_alter() function, is defined as my_menu_module_form_alter(). This code below searches for any content add/edit form and sets the checkbox to default to checked:
function my_menu_module_form_alter(&$form, &$form_state, $form_id) { if (substr($form_id, -10) == '_node_form') { $form['menu']['enabled']['#default_value'] = TRUE; } ]
I'm pretty sure that's not exactly what we want to do, though. This is where Drupal's built-in variable system is very helpful. Using the functions variable_set() and variable_get(), you can set/get small bits of data very easily. In this case, we're just setting "1" or "0", which is synonymous in this case to TRUE or FALSE. Therefore, this is the version of the above function where we get the content type name from the form id and then check a variable that is specific to that content type.
function my_menu_module_form_alter(&$form, &$form_state, $form_id) { if (substr($form_id, -10) == '_node_form') { $content_type = substr($form_id, 0, -10); $form['menu']['enabled']['#default_value'] = variable_get('my_menu_module_' . $content_type . '_enabled', FALSE); } }
Now, we need to create a checkbox on the Content Type edit page. To do that, we'll use another form_alter function:
function my_menu_module_form_node_type_form_alter(&$form, &$form_state, $form_id) { $form['menu']['my_menu_module_enabled'] = array( '#type' => 'checkbox', '#title' => t('Default the "Provide a menu link" item to checked.'), '#default_value' => variable_get('my_menu_module_' . $form['#node_type']->type . '_enabled', FALSE), ); $form['#submit'][] = 'my_menu_module_type_form_submit'; } function my_menu_module_type_form_submit($form, &$form_state) { variable_set('my_menu_module_' . $form_state['values']['type'] . '_enabled', $form_state['values']['my_menu_module_enabled']); return; }
Also, as you can see, I added a submit function that saves our custom variable. You'll also notice that the variable_get() function always expects a second variable which is the default value if this variable is not set. So, now you should have a much more functional module that has a checkbox on each content type's admin interface to decide if this will be defaulting to true on your site's content types.
Update: My co-workers have created a Drupal module out of this idea. Check out the Default Menu Link module. It might just help you out.
Blue Like Jazz, Christianity, and the Movies
Over eight years ago, a young man named Donald Miller released a soon-to-be bestseller, Blue Like Jazz: Non-Religious Thoughts on Christian Spirituality. I read it a couple months ago, and I found it to be a non-conventional set of reflections on what God, Christianity, and religion is in this modern world. In the same way, I'm happy to say that the story and characters in Blue Like Jazz: The Movie will get you thinking about these ideas and discussing them with your friends.
In the film, we find Donald Miller's character getting ready for college and finding himself disillusioned with the Texas Baptist church he grew up in. He decides to go to a whole different world -- a free-thinking institution in Portland, Oregon called Reed College. Despite meeting a whole bunch of new friends who dislike Christian culture and religion, he finds his beliefs and Christ's love still may have a place in his life. It's a good screenplay with plenty of drama, humor, and engaging discussions written by Donald Miller himself. The film adaptation of Blue Like Jazz is also well-directed and produced by filmmaker and former musician Steve Taylor and his Nashville-based crew.
The film, although created by Christians, is far from what anyone considers a "Christian" film. The film premiered to agreeable audiences at SXSW a month ago, and contains almost nothing of what is often associated with Christian films. There is no scenes of preachers talking to the camera. Blue Like Jazz has no "conversion" experience or anyone praying over another person for them to be "saved". The acting is well-done and none of the sets look like they came from a soap opera. Instead, homosexuals are treated as just a character and not preached to. In addition to the rigorous academic atmosphere at Reed College, drug use, drinking and other activities on campus are portrayed as well. There are some scenes that poke fun at the insular Christian sub-culture, which may also disturb some believers who are proud of being apart from the rest of the world. The film is rated PG-13 and is distributed through Roadside Attractions, which also released Winter's Bone, Margin Call, and Biutiful.
While Blue Like Jazz is not the best film I've seen in this past year, it is definitely worth a look. Also, as a Christian, I like to support films that portray Christianity in a genuine and realistic way. This film does this the best I've seen in a widely-released film created by Americans in years. I was fortunate to see an early screening a couple weeks ago, and after the film was shown, director Steve Taylor urged Christians to support the film. Roadside Attractions, a small independent distributor, has taken a risk on a type of independent film that often does not see the light of day. (In fact, the film was partially funded by fans on crowd funding website Kickstarter, of which I gave $50 to support the film.) Taylor stressed that if the film does well in the first 24-48 hours, it can give a message to Hollywood that there is a market for films made by Christians. So, by all means, if you're interested in supporting films made by Christians or are intrigued by the film, please visit a local theater playing Blue Like Jazz.
Blue Like Jazz: The Movie opens in major markets this Friday, April 13. I, along with a couple friends, will be going out to screen the film at the Block e theater in downtown Minneapolis. Please watch the trailer and find a theater near you if you're interested in joining the discussion. If you do go and see Blue Like Jazz, please tell me what you think -- I'd love to hear your thoughts.