# The overall structure of foundry

## Top level structure

Foundry supports two kinds of themes: Parent themes and child themes. Parent themes are also called master themes. Normally there should be only one parent theme in a CCM installation at `/themes/foundry`. All other themes should be child themes. An example for a child theme should also be installed at `/themes/foundry-base`.

A complete Foundry theme (a parent theme) contains of the following directories:

`conf`
  Configuration files for the theme.
`doc`
  The documentation of Foundry. The document you reading at the moment is generated using these files.
`fonts`
  Webfonts used in the theme.
`foundry`
  The directory contains the XSL files which contain the logic part of Foundry.
`images`
  Static images for the theme.
`libs`
  Additional JavaScript libraries, for example jQuery plugins.
`scripts`
  Custom JavaScripts
`styles`
  CSS files
`templates`
  The layout templates
`texts`
  Static texts for the theme
`user`
  Custom extensions. Not supported yet.

A child theme has only the directories which contain files which the designer needs to change. These are:

- `conf`
- `fonts`
- `images`
- `libs`
- `scripts`
- `styles`
- `templates`
- `texts`

The `foundry` directory contains the following files and directories:

`fonts`
  Webfonts used internally, for example for the Content Center.
`images`
  Images used internally.
`lib`
  The XSL files from Foundry.
`scripts`
  Java Scripts used internally.
`styles`
  CSS files for internal templates like the Content Center
`templates`
  Internal templates for example for the Content Center.
`texts`
  Internal texts
`main.xsl`
  Entry point. The `start.xsl` in the base directory acts only as entry point for the XSL processor and delegates all work to the `main.xsl`.
`lib.xsl`
  A simple import file which imports the XSL files from the lib directory.

The `main.xsl` file contains the `xsl:output` element which tells the XSL processor that we want to create HTML. There is only two XSL templates in the `main.xsl` file along with some helper functions. This first template is the entry point for CCM and matches the `bebop:page` element which is the root element of the data tree XML created by CCM. The template processes the `conf/templates.xsl` file calls the XSL templates for parsing the layout templates.

The second templates is the entry point for the documentation system Foundry.

## The lib directory

The `lib` is the core part of Foundry and contains the following sub directories and files:

`bebop`
  XSL files for creating the backend UI. The XSL files were taken from Mandalay and have only been adapted to work inside Foundry.
`search`
  XSL files for the various search applications.
`template-tags`
  XSL files implementing the tags which can be used in the templates.
`template-tags`
  This directory contains the XSL files which implement the tags which can be used in the layout templates.
`bebop.xsl`
  Imports the files from the `bebop` directory.
`global-vars.xsl`
  These file is very important. It defines various global variables like the `theme-prefix` or the `context-prefix` variables. A complete list can be found in the reference part.
`search.xsl`
  Import file for the XSL files in the `search` directory.
`template-parser.xsl`
  This file contains the XSL templates for parsing the layout templates.
`template-tags.xsl`
  Import file for the XSL files in the `template-tags` directory.
`utils.xsl`
  Helper functions. A complete list is available in the reference part.

## Template tags

The `template-tags` directory contains the XSL file which are implementing the tags which can be used in the layout templates. For a complete list please refer to the Template Tags Reference in the user manual.