Drupal Development FAQ
11 Sep 2015 | Ben RobertsonWhere are the sites theme files?
Where do I add css/javascript?
What css compiler do we use?
Where does the css compiler go?
Where do I add external javascript files (ie. Typekit, Google Fonts)?
Where are the theme templates?
What is the naming convention for theme template files?
How do I get content to appear on the page?
Where do I install modules?
What modules should I use in development?
What non-core modules should I use?
What folders need to be excluded from git?
Where are the sites theme files?
app/sites/all/theme/themename
Where do I add css/javascript?
CSS and JS that need to be included in the theme should be added in the themename.info file. Each time you add a new stylesheet or script, you will need to clear the Drupal cache before your changes will become active.
Stylesheets go like this:
stylesheets[all][] = compiled_css/merge.style.css
Scripts go like this:
scripts[] = js/main.js
What css compiler do we use?
SASS with Compass
Where does the css compiler go?
Sass should be configured to compile to themename/compiled_css/merge.style.css
.
sass files should be in themename/scss
. Please use scss syntax
Where do I add external javascript files (ie. Typekit, Google Fonts)?
External javascript should be added in the themename/template.php
file.
Do it like this:
Where are the theme templates?
Theme templates should be kept in a folder called templates within the theme folder. The templates should be organized into folder within the template folder based on what content they template. Here is the Drupal template hierarchy (most general to most specific):
- Page
- Region
- Block
- Node
- Fields
If you are using flexible content (ie. Paragraphs module and Field Collection module), then you will also have paragraph items modules and field collection modules.
Most of the default Drupal templates are located in app/modules/system
. Default field template is in app/modules/field
, default node template is in app/modules/node
. You can override these templates in your theme by creating an identically named file in your theme and styling it.
What is the naming convention for theme template files?
A comprehensive list of naming conventions for theme template files is located here.
How do I get content to appear on the page?
To get content that you have entered in the backend to appear, put this in your page.tpl.php
:
For any other template, you can use
$content
is an array with various sections. You can show or hide various sections (ie comments and stuff).
Where do I install modules?
sites/all/modules
What modules should I use in development?
####Devel and Devel Themer
Devel enables a bunch of development features. The one I use the most is the krumo()
function, which when you pass a variable (like $content
) to it shows you all the arrays/properties of that variable.
Devel Themer will give you a nice overlay that lets you see what variables are available in different regions on the page.
What non-core modules should I use?
Flexible Content
- Entity API
- Paragraphs
- Field Collection
- Link
- use this for any CTA / Link field. Makes CTAs so much better.
Parent/Child Relationship
WYSIWIG Editor
- CKEditor
- Better Formats
- Allows us to control which fields get a CKEditor or plain text.
- There are some good recommendations here for WYSIWYG considerations in Drupal
Image Management
jQuery version
- jQuery Update
- Allows you to set Front-End jQuery version and Backend jQuery
Better URL Structure
What folders need to be excluded from git?
sites/*/*settings*.php
/sites/*/files
/CHANGELOG.txt
/COPYRIGHT.txt
/INSTALL*.txt
/LICENSE.txt
/MAINTAINERS.txt
/UPGRADE.txt
/README.txt
sites/all/README.txt
sites/all/modules/README.txt
sites/all/themes/README.txt
**/.sass-cache
**/.sass-cache/*
**/compiled_css/*
/cache