wiki:DeveloperGuidelines/Templates

Version 3 (modified by Fran Boon, 9 years ago) ( diff )

compile templates needs latest web2py or hardcoding theme name

Templates

Introduction

Templates allow selecting alternate configuration sets.

This allows a separation between Core Code & Settings/Custom Code.

This helps prevent merge conflicts between different deployment branches & hence reduces the risk of forking.

Design

Configuration is done using these files:

  • /private/templates/000_config.py
  • /private/templates/default/config.py
  • /private/templates/<template>/config.py

During 1st_run, 000_config.py is copied to models/

000_config.py includes:

  • FINISHED_EDITING_CONFIG_FILE
  • VERSION
  • machine-specific configuration (Debug, Database, SMTP, API Keys, etc)
  • a setting to define which template folder to run
  • importing of settings from templates/<template>/config.py
  • optional local overrides to the template's settings

Prepopulate Data

Prepopulate options are defined in the template's config.py (ut can be overridden in the running 000_config.py):

Theme

By default these files are used:

  • /private/templates/default/views/layout.html
  • /private/templates/default/views/style.html (for non-Debug mode)
  • /private/templates/default/style.cfg (for Debug mode)

Optionally a template's config.py (or running 000_config.py) can specify a 'theme' folder (usually the same as the template folder), so that these are used instead:

  • /private/templates/<theme>/views/layout.html
  • /private/templates/<theme>/views/style.html (for non-Debug mode)
  • /private/templates/<theme>/style.cfg (for Debug mode)
  • static/styles/<template>/sahana.min.css

By convention, suporting files specific to this theme should be placed in:

  • static/styles/<template>/*.css
  • static/img/<template>/*.png

NB Production sites who wish to compile their code either need to hardcode the theme name in their views/layout.html & views/style.html or upgrade to Web2Py version: 2.00.0 (2012-06-17 23:36:32) or newer

ToDo

  • controllers/default.py index()
  • modules/eden/layouts.py & modules/eden/menus.py

References


DeveloperGuidelines

Note: See TracWiki for help on using the wiki.