• Development

    Sending HTML Emails from a Drupal 7 Site

    It was a little more difficult than I’d hoped to track down the proper method for sending HTML emails from Drupal 7. I’m working on a problem with Webform, so Webform emails were my primary concern. I’m not going to spend any time explaining the solution. I encourage you to look into the modules if you’re interested in learning more.

    1. Download and enable mailsystem
    2. Download and enable htmlmail
    3. Visit /admin/config/system/mailsystem
    4. Choose “HTMLMailSystem” as the mail class for all applicable “modules”
      1. To add a module (e.g., Webform), open the “New Setting” at the bottom and choose:
        1. Module = Webform
        2. Key = leave blank
      2. Save settings
      3. Update that module to use the HTMLMailSystem
    5. Try it out.
  • Development

    Devel Generate Text Settings

    Devel Generate, which is part of the Devel module, makes it really simple to create dummy entities in Drupal. It’ll create everything from users to taxonomy terms to nodes. It does a great job of populating most field types (including images). Sometimes it’d be nice to have more control over the output that it’s generating. In particular, text fields often get populated with too much text.

    I’ve written a module to solve this dilemma.

    The Devel Generate Text Settings module lets you control the length and format (sentence structure vs. title) of text and long text fields. It also lets you easily add a prefix to the title of the nodes being generated.

    One problem you may have run into is for fields that need a limited amount of words or characters. Imagine you have a Father’s Name field. Most of the time you’d expect to see two words (first name and last name). Devel Generate will almost certainly generate more than two words for this field. It may even generate 40! That’s not desirable. We need the dummy content to appear as close to the real thing as possible.

    Devel Generate Text Settings gives you the ability to tell Devel Generate to stay within a certain word count, or even hit an exact word count. It also allows you to set the “treat as title” value to true, which removes any punctuation from the generated text and capitalizes the first letter of each word.

    Here is what the rule might look like for the field in this example:

    The breakdown is: when generating content for the field_father_name field, generate either one or two words. Exclude punctuation and capitalize the first letter of each word.

    This is just a sandbox project for now, and it only works with nodes.

    Here’s a screenshot of the admin at the time of writing:


  • Tech Tips

    Grabbing Screenshots for a List of URLs

    UPDATE: There’s a better tool for this job. View my new post about Pageres.

    webkit2png is a great tool for taking automatic screenshots of websites. Here’s the project’s description: “With tall or wide pages that would normally require scrolling, it takes screenshots of the whole webpage, not just the area that would be visible in a browser window.”

    Here’s one way to use this tool to grab an entire list of URLs. First, make a file containing URLs, one per line. Next, simply run this (set filename, output directory, and options as needed):

    The “-F” argument will grab only a fullsize screenshot. There are many options to control sizing, filenames, scaling, and more. Run  webkit2png --help for available options.