Table of Contents Previous Next

Sugar Developer Guide

Version 5.1


Chapter 4 Customizing Sugar : Creating New Themes : Overview

Overview
Every time a Sugar screen is rendered to the browser, the system loads a Sugar theme for display based upon the value set in the variable:
$_SESSION['authenticated_user_theme'];
 
If no value is set in the authenticated_user_theme variable, then Sugar will use the value set in:
$GLOBALS['sugar_config']['default_theme'];
 
Understanding exactly where and how $_SESSION['authenticated_user_theme'] is set is less important at this point than understanding the basic logic behind it:
o
o
o
You will see at the bottom of index.php that the HTML is eventually rendered by calling or "including" the following three files:
include('themes/'.$theme.'/header.php');
include($currentModuleFile);
include('themes/'.$theme.'/footer.php');
 
The $theme value defines which header and footer are used from the themes directory. Each screen is essentially a "header" and "footer" wrapped around the $currentModuleFile "body", which is determined by the POST parameters sent into index.php.
Each directory underneath the <sugar_root>/themes/ directory defines a different theme. There are certain files that every SugarCRM theme must contain. Those are:
o
themes/<your_theme>/config.php - defines the name of the theme and the minimum Sugar version the theme will work in.
o
themes/<your_theme>/footer.php - defines the HTML rendered at the bottom of the page.
o
themes/<your_theme>/header.php - defines the HTML rendered at the top and the left of each page.
o
themes/<your_theme>/layout_utils.php - defines a series of helper functions that draw the HTML for group boxes round forms and other layout components. By modifying the code in this file, you can change the look and feel of form headers/footers, form titles, graphs, etc. A designer could choose to organize the logic included in these files in any matter he sees fit.
o
themes/<your_theme>/style.css - defines the style sheet for the theme. All of the different classes used throughout the app are typically defined in this file. You could break them out into other files if you so chose, but the convention is to use style.css.
o
themes/<your_theme>/header.html - we use a PHP template library called Xtemplates for separating the business logic from the presentation in the app. Xtemplates essentially allow you to define a series of dynamic tags in a PHP file (header.php in this case) and then reference those tags in an HTML file. You are not required to use a header.html with your header.php, but it is the convention.

Table of Contents Previous Next

Copyright 2004-2008 SugarCRM Inc.
Product License