BEST PRACTICES & CONVENTIONS
To create new themes, it is important that authors write clean, well structured-code just like a coder for any other project. Doing so makes the codes easier to read, understand and maintain. While different organisations have different conventions, it's usually best to follow the Drupal standards as this helps when collaborating or asking for help.
Here are some simple standards to follow when creating a theme:
- Add 2 spaces for indents; rather than a tabbed indent to maintain consistency.
- Match the indentation of long opening and closing block HTML tags.
- Distinguish between PHP and HTML indentations.
- Prefer PHP in HTML to HTML in PHP in templates.
- Separate logic from presentation.
- Always put a semicolon at the end of your small PHP printing statements.
