• 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.

  • Drupal's Weak Link

    Gabe Sullice

    One of the things I love about Drupal is the entity reference field. In Drupal 8, entity reference fields are even better because they’re now included in Drupal Core. This makes building composed and well-structured data much easier. However, I think as Drupal developers and architects, we’re fundamentally misusing them in far too many cases. Over and over, we use entity references to denote a relationship between two entities instead of a simple reference or inclusion.

  • 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.

  • Drush Tools for Inspecting Configuration

    Rob Ballou

    I have a confession to make: I don't like clicking through the Drupal admin. Over the course of a project, beit one with content migrations, configuration in code, or just general site building, the information I need the most is field and taxonomy configuration. Typically, this means bouncing betweens tabs for content types and taxonomies which consumes time and precious clicks. Add in custom entities in our new Drupal 8 projects and there's even more time spent in the admin.

  • Introducing an HTTP API for Drupal 8 Entity Queries

    Gabe Sullice

    Drupal 8 lays the foundation for building robust and flexible RESTful APIs quickly and efficiently. Combine this with Drupal’s best-in-class fieldable entity model and it becomes incredibly easy to construct systems that solve many different problems well.

    Out of the box, Drupal 8 comes with core modules for all of the standard RESTful HTTP methods, GET, POST, PATCH, and DELETE. These endpoints are entity specific. Collection endpoints - endpoints that deal with entities in aggregate - are another story. The solution offered is the Views module.

  • Drupal 8: Programmatically Adding a Views Footer

    Joel Steidl

    Recently, I needed to add some dynamic content to a Views footer. Specifically, I needed to change a link in the Views footer based on the current path, which isn’t an option from the Views UI. I found some good documentation showing how this can be done in older versions of Drupal (https://www.drupal.org/node/749452), but nothing for Drupal 8. I figured the approach must be similar in Drupal 8 so I started searching and reverse engineering.

Pages