Drupal 7 is the last major release of the Drupal CMS and is will be supported by the Drupal community until Drupal 9 gets released. Drupal 7 is similar to previous versions of Drupal using a system of hooks to allow us to do much of the heavy lifting and to seamlessly tie in to the Drupal way of doing things. Take a look at some of our Drupal 7 articles below...
This is a real quick one, but so useful! We often want to render a block within content, perhaps as part of a node (maybe in hook_node_view, and then made configurable like a field), but there's no obvious way to do this correctly for any block. Drupal normally renders its blocks per region, so there is no single function to embed a block. I came across this really simple solution by Damien Tournoud in a...
UPDATE: The Extra Field and Extra Field Settings Provider modules facilitate doing this sort of thing in Drupal 8. Read on for older Drupal sites, and for the concepts behind this. We often want to add things to the content of a node or any other entity in Drupal 7 using hook_node_view(), hook_node_view_alter() or a similar hook in a custom module. This could be anything from a custom social media link, a field rendered in...
Drupal 7 brought us Entities, and with them the powerful [Field API][] for 'storing, loading, editing, and rendering field data.' attached to them. If you're managing everything through 'manage fields' and 'manage display' tabs of your content type, then every part of that process is rather wonderfully taken care of for you. [Field API]: http://api.drupal.org/api/drupal/modules--field--field.module/group/field/7 We often, however, come across the need to render a field outside the context of it's entity. A common example might include rendering a node's author in a sidebar block. Sure, modules like Panels and CCK Blocks will do this for you, but doing it manually is actually not that hard.
In Drupal 6, if you called node_load then what you'd be returned would be your own copy of the node to change and modify as you pleased, but in Drupal 7 this was changed. By default, what you actually get back from a node_load is essentially a reference to a global singleton for that node. This has the interesting side effect of meaning that if you change anything in the node object, you are probably...
Here's a quick follow-up to my original post on Dynamic forms in Drupal 7, as a reply to Wappie08, who asked me about combining conditions in the #states array to add increased control over the display of your form elements. The question: Hi James Williams, I read your blog post about d7 & #states in the FAPI which is really cool! One problem is that the information is also listed in the drupal.org example module...
Here's a quick post that will be a reminder for us as much as anyone else! Setting the default theme during installation using an installation profile is surprisingly hard in Drupal 6, and easier though not obvious in Drupal 7. In Drupal 6, we used the wonderful Install Profile API module, which allowed us to do it in just a few lines in an install task: install_enable_theme(array('my_theme', 'garland', 'rubik')); install_default_theme('my_theme'); install_admin_theme('rubik'); In Drupal 7, here's...
Boosting terms in Solr search results produced by the Apache Solr Search module that integrates Solr with Drupal is something we had to do for a project recently. If a user has come to our website from a search engine, we can pick up the terms that they had originally searched for - and then boost any documents containing those terms in our own search pages, regardless of what they search for on our pages...
Creating extra field formatters in Drupal 7 is fairly simple, but it can take some poking around in the new Fields code. So here is some sample code to make it easier for you! You can add formats to your own fields -- or existing fields that are defined by other Drupal modules. This is the case for the following example - a formatter for a link field to display the URL as an absolute...
When building forms, you will often want to only provide certain options if other options are chosen by a user. For example, there's no need to show the 'open link in new window' checkbox, if the 'make this into a link' checkbox hasn't been ticked. These kinds of dynamic forms haven't been easily available for Drupal... until now, with the #states for form elements in Drupal 7. Take a peek at this example of dynamic...
Certified to Rock is a site that allows you to look-up Drupal.org user names, and see their 'certified to rock' score. CertifiedToRock.com is a way that community members and employers can get a sense of someone's involvement with the Drupal project. The site uses a custom algorithm that gathers publicly available information which is then distilled down into a score on a scale from one to eleven. I've been wanting to build an easy way...