| 1 | = Work Standards = |
| 2 | |
| 3 | Drupal is powerful and flexible. There are often many alternative solutions to any problem. Drupal is also a thriving community, made up of lots of people with different (sometimes conflicting) ideas. And Drupal changes quickly. If the community finds a better way of doing something, they often drop older methods. That means if you're not careful, your Drupal website could become difficult to upgrade if the tools and approaches you use become deprecated. |
| 4 | |
| 5 | When you build with Drupal, you're accepting both the good and the bad in this. The best way to avoid the bad, is to keep your working practices closely in tune with the majority of the Drupal community. "Go it alone" at your own risk. Or rather, don't! In the Transition Network, we like to minimise risk. |
| 6 | |
| 7 | Being a member of the Transition Technologists team means you agree to follow these best practices. Ignoring them will undermine collaboration and cost us more time and money in the long-term. |
| 8 | |
| 9 | == Choose well-supported modules with a strong history and developer base == |
| 10 | |
| 11 | When picking "contributed" Modules (Modules that aren't included in Drupal Core, but are available through the community at drupal.org/project/modules), try to use the following criteria when picking new Modules to add: |
| 12 | |
| 13 | * Has the statuses "actively maintained" and "under active development". |
| 14 | * Reportedly in use on at least a few thousand website. |
| 15 | * Have evidence of long-term development. (Look for versions for the last one or two Drupal versions before the current one). |
| 16 | * Shows commitment to prompt future upgrading - many modules say something like "we commit to having a Drupal 8 version available on the day Drupal 8 stable is released". |
| 17 | |
| 18 | Beyond that, it also help to double check modules that perform a similar function to each other, read through their issue queues, and look for signs that they might be merging, or becoming deprecated. If in doubt, ask in the Drupal forums, or ask a more experienced Drupal developer on in the Transition Technologists team. |
| 19 | |
| 20 | == Follow Drupal coding standards == |
| 21 | |
| 22 | Drupal has some fairly clear [[https://drupal.org/coding-standards|coding standards]]. It's not about one way being more right than another, but following Drupal's standards helps us keep our code consistent for when newcomers have to pick up where we left off. So, follow them! |
| 23 | |
| 24 | == Pick good names for things == |
| 25 | |
| 26 | Names for things (CSS classes, Views, Content Types, Panels) are often very hard to change. So choose once and choose well. Make names: |
| 27 | |
| 28 | * Descriptive and intuitive. |
| 29 | * Concise (a compromise with with "Descriptive and intuitive"). |
| 30 | * Extensible. |
| 31 | |
| 32 | Most of us building with Drupal will be responsible for naming things. If we're developing HTML+CSS, we may need to define class names. If we're building Views and Panels, we need to give those things "machine names". Unfortunately, it's difficult to set rules for naming. It requires creativity, judgement and common-sense. So here's some good vs bad names which hopefully give you an idea. |
| 33 | |
| 34 | ||= Context =||= Bad =||= Good =|| |
| 35 | || CSS class for a coloured box || .yellow-bg (colour might change in future) || .highlighted || |
| 36 | || View name for a latest news page || latest (too vague) || news_latest || |
| 37 | || View name for an events listing || calendar_3 (too vague, may not always be a calendar) || events || |
| 38 | |
| 39 | == Try to group Views together == |
| 40 | |
| 41 | The Views module makes it possible to create multiple displays under one View. For example, a page, a Block, and a Panels content pane. We should avoid creating all of these as separate Views, for two reasons. |
| 42 | |
| 43 | Firstly, we'd be missing out on an opportunity to reduce work. When Views displays are grouped under one View, adding a Field to one display can add that Field to all grouped displays. We can also override a specific display where needed, but there is the ability here to minimise work and make global changes. |
| 44 | |
| 45 | Secondly, the Views admin page is hard enough for newcomers to wade through as it is. The more Views displays are grouped, the easier it is to look at the Views admin page and work out what's going on, where. |
| 46 | |
| 47 | Great practice for naming various views displays is thus (the machine name for the following view might be "news"): |
| 48 | |
| 49 | ||= View display =||= machine name =|| |
| 50 | || Main news page || news_all || |
| 51 | || Latest news Block || news_latest || |
| 52 | || Related news Block || news_related_tag || |