• Adding Descriptions to Drupal 7 Checkboxes and Radios

    James Nettik

    Recently, I was creating a form that provided a list of options as checkboxes and needed to include helper text for each individual checkbox. While the Form API in Drupal 7 has a #description attribute, for checkboxes and radios it applies that as text for the entire group. After a lot of looking, there didn't seem to be a way that allowed for passing descriptions into each item in the #options array that is expected.

    Filed under:
     CodeDrupalDrupal Planet
  • Create Comments in Drupal 8 Programmatically

    Gabe Sullice

    Creating comments programmatically in Drupal 8 is incredibly easy once you know just which fields are required and why. In Drupal 8, comments are now full-featured, fieldable entities — just like nodes or taxonomy terms. In addition to unifying the way we create content, comments, and other entities, this has made Drupal’s commenting system much more robust and flexible.

  • Easy Browser Support with Polyfill.io

    John Ferris

    Finding and installing polyfills can often be a tedious task. Not too long ago, I was searching for a good list of polyfills to reference while working on browser compatibility issues. I ended up coming across Polyfill.io, a service that has since proven very useful.

    Polyfill.io makes polyfilling support for newer JS features in older browsers super easy. It works via User-Agent sniffing to determine the browser being used, then loads the required polyfills.

    Here’s how you use it

    Filed under:
  • Creating Dynamic Columns on a Feeds Importer

    James Nettik

    Drupal’s Feeds module is a great tool for importing content into a site. The Feeds UI is relatively simple, and it’s fairly full featured out of the box. One such feature is the ability to assign a unique ID to each item. This allows sequential imports to determine if an item of content has already been imported and how the site should handle that situation. The options here include:

    Filed under:
  • Making region content available to node templates in Drupal 8

    Brian Gervais

    Why would you need to render the content from Drupal’s block layout via a node template file? Normally, that is the territory of page templates. The use-case for me was a page where node-specific fields were mixed in with blocks to the extent that rendering region content in a page template file wasn't going to work.

    I needed to be able to render my region content amidst field values in my node template files. Drupal doesn't let you do that out-of-the-box.