theming

YAML formatting and Drupal 8 - making things readable

As someone who loves YAML syntax (so much more pleasant to work with than JSON!), I wanted to jot down a few notes about syntax formatting for the benefit of Drupal 8 developers everywhere.

I often see copy/pasted YAML examples like the following:

object:
  child-object: {key: value, key2: {key: value}}

This is perfectly valid YAML. And technically any JSON is valid YAML too. That's part of what makes YAML so powerful—it's easy to translate between JSON and YAML, but YAML is way more readable!

So instead of using YAML like that, you can make the structure and relationships so much more apparent by formatting it like so:

Preserve the ability to Quick Edit nodes when theming node templates!

...aka, avoid the annoying Javascript error below:

drupal.js:67
TypeError: undefined is not an object (evaluating 'entityElement
      .get(0)
      .getAttribute')

Many themers working on Drupal 8 sites have Contextual menus and Quick Edit enabled (they're present in the Standard Drupal install profile, as well as popular profiles like Acquia's Lightning), and at some point during theme development, they notice that there are random and unhelpful fatal javascript errors—but they only appear for logged in administrators.

Eventually, they may realize that disabling the Contextual links module fixes the issue, so they do so and move along. Unfortunately, this means that content admins (who tend to love things like contextual links—at least when they work) and up not being able to hover over content to edit it.

There are two ways you can make things better without entirely disabling these handy modules:

Hide the page title depending on a checkbox field in a particular content type

In Drupal 8, many small things have changed, but my willingness to quickly hack something out in a few lines of code/config instead of installing a relatively large module to do the same thing hasn't :-)

I needed to add a checkbox to control whether the page title should be visible in the rendered page for a certain content type on a Drupal 8 site, and there are a few different ways you can do this (please suggest alternatives—especially if they're more elegant!), but I chose to do the following:

  1. Add a 'Display Title' boolean field (checkbox, using the field label as the title, and setting off to 0 and on to 1 in the field settings) to the content type (page in this example).

    Drupal 8 Basic Page 'Display Title' checkbox

Moving from Drupal 6 to Drupal 7 - A Themer's Perspective

The transition from Drupal 6 to Drupal 7 has taken a bit of time, and I (like many others) simply haven't had enough time in the past few months to do D7 testing while in the midst of tens of other D6 projects.

I've committed, though, to building out three Drupal sites in Drupal 7, now that we're at beta-3, and I will be posting a few reflections, mostly from a themer's perspective on some changes—the good, the bad, and the confusing.

A New Default Theme - Bartik

Just like Drupal 5/6's default theme, Garland (which is in use on this site right now :-/), Bartik will be seen on thousands of quickly-built sites around the web, and I think the theme is robust enough for this purpose. I'm actually building one site's theme directly on top of Bartik, just modifying CSS through a single stylesheet added by a custom module.

But it's nothing amazing, in my opinion. I think it would've been awesome to have some sort of dropdown menu support in core by this point—but it looks like that will wait until Drupal 8 at least. This is probably the number one most requested feature I get on a lot of the smaller sites I'm asked to build, and having the feature in core would be über-cool.

Building a Theme for Drupal 7

After having built out many themes for Drupal 6 (and a couple for Drupal 5), I'm going to start from scratch on a couple designs and build a theme in Drupal 7, which will be released sometime in 2010. I'll take you along my journey in this article.

Please note, this article is a work in progress, and I'll be updating it as I go. Hopefully, within a couple weeks, I'll have the article complete, and a nice new theme to release on Drupal.org (maybe), only for Drupal 7.

To get things kicked off, here are a few articles that have good background information on Drupal 7 theming:

My CVS Workflow for Updating a Theme on drupal.org

Drupal CVS <ugh> Druplicon FrownFrom time to time, I've had to update my airyblue project in CVS (Airy Blue is a light, airy, Zen subtheme listed on Drupal.org's Themes section). It's always a bother, and I always end up spending about 20 minutes figuring out how to check out the module to my local computer (I use three of them, so even if I have it set up on one, I need to get it going on another sometimes), then another 20 figuring out how to commit my changes, tag a release, etc.

So, this post might be titled "How to Maintain a Theme on Drupal.org if You're Confounded by the CVS Guide for Theme Maintainers, and you are on a computer on which you haven't checked out your module yet."

Logging in, Setting up CVSROOT

Designing a Good Website

This article will help you to learn some fundamental principles in web design and to design your own nice-looking, functional website

Over the past eight years (ever since I've owned a Macintosh), I've designed many different websites. I've dabbled in different web programming languages and done many, many technical tasks (some of which I don't remember how to do). But does this make me a good web designer? Not necessarily. I've learned through experience and research only so much about web design. It's more of an art than a science really; but it takes a lot more than an artist's mind to design a functional and eye-catching website.

Full Site Buildout: Part 2 - Theme Development

Part 2 of a series: Building out a full Drupal site in a weekend.

Well, one plane flight down, and a conference to go, I have the main structure of the theme set up (locally; haven't pushed it out to opensourcecatholic.com yet). I decided to go with Zen 2.x's -dev releases, for the simple fact that it's new and the way the Zen project is moving. There are a few rough areas in the documentation, mostly in the 'Readme' file for installing a subtheme, but I got through everything okay.

This theme, I hope, will make its way onto the fine Drupal.org theme repository; getting a CVS account, I'm sure, will be fun ;-)

Let's Get Through the PHPTemplates!

I just finished rolling a patch for fixing node.tpl.php in Drupal 7 over on the Drupal.org issue queue; hopefully it's ready to be rolled into core, as it's been weeks months since that particular issue was started. Page.tpl.php is already complete. We still have a few more to go, including comment.tpl.php, block.tpl.php and a bunch of little .tpl.php files.

I think Drupal 7 is going to be the best release of Drupal yet, in terms of being able to have a lot of appeal to non-programmers/techies. I set up my first ever full-fledged Wordpress site a few days ago, and it was super-easy to get things going (although also severely limited in what it could do, compared to a base Drupal install with Views and CCK), choose a new theme, change some settings, and hit the ground running.