Topics

Theme Template Structure

Overview

This guide will show how to set up a theme in Exponent CMS 2.0. It covers how to best interact with the system, and make the most out of your Exponent project.

Parts and Pieces
An Exponent website ban be broken down in to two major components: themes and views. Themes (also known as Theme Variations and Subthemes) comprise the overall structural framework (HTML and CSS defining columns, header, foot, etc..), of the website, while views (smarty templates) display a particular module’s content (news, text, blog, etc..). The theme file itself, located in /themes/mynewtheme/index.php, intermingles HTML with some Exponent specific PHP functions to form the base for your website's theme.

Themes
Theme files are the shell of your site. Comprised of mostly HTML, they require the use of three (3) php function calls, with an optional fourth. The main idea is to give a theme designer complete control over their layout, only plugging into CMS functionality where needed. The four (4) functions (class methods of expTheme) are:

  • expTheme::head(); // required
  • expTheme::main(); // required
  • expTheme::module(); // optional
  • expTheme::foot(); // required
<html>
<head>
<?php
    expTheme::head(array(
        "xhtml"=>true,
        "normalize"=>true,
        "css_core"=>array("common"),
        "css_links"=>true,
        "css_theme"=>true
    ));
?>
</head>
<body>
    <?php
      expTheme::main();
    ?>
    <?php
      expTheme::foot();
    ?>
</body>
</html>

expTheme:head(array);
This required theme function is used to open the page and takes an array of parameters most of which pertain to the CSS portion in Exponent’s Theming Engine.

expTheme::head(array(
    "xhtml"=>false,
    "normalize"=>true,
    "css_core"=>array("common"),
    "css_links"=>true,
    "css_theme"=>true
));
?>

expTheme::main();
This required theme function call Is the meat and potatoes of Exponent functionality, acting as a 'sectional' container which displays all the contents (and controls) of its included modules.

expTheme::module(array);
This optional function is a unified way to 'hard-code' modules into the theme. expTheme::module() method allows for hard coding modules. expTheme::module() takes 1 parameter, an array, describing what module to hard code on the page.

// hard coding a controller
expTheme::module(array(
   "controller"=>"links", // the name of controller (exp2 mod) to display
   "action"=>"showall", // the action (class method) to run
   "view"=>"showall_quicklinks",  // the view to display
   "source"=>"footer", // the source, the name of the content object
   "scope"=>"global",  // the scope, either 'sectional', 'top-sectional', or 'global' (by default)
   "chrome"=>false // show or hide the chrome on this module (red chrome for hard-coded modules)
));

expTheme::foot();
This required theme function call is used to close out the page and place the appropriate css and javascript entries..

Loading Help