J4.x

Cassiopeia Template Folders and Files: Difference between revisions

From Joomla! Documentation

No edit summary
 
(31 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{underconstruction}}
<noinclude><languages />{{Joomla version|version=4.x}}</noinclude>
<translate>
== Introduction == <!--T:1--></translate>
<translate>
<!--T:2-->
Newcomers to Joomla, sometimes new to PHP too, may know little of the architecture of a Joomla website and how it all comes together to present a website to the end user. That was me in 2010! However, having arrived here you will realise that Cassiopeia is a Site Template that controls the appearance of a site as seen by the general public. Administrators use a different template, Atum, with a completely different appearance. These templates are sometimes referred to as Frontend and Backend templates.</translate>


== Introduction ==
<translate>
<!--T:3-->
A template is a Joomla extension that consists of a collection of files that take care of different aspects of the presentation. A website may have a number of site templates, one of which must be chosen as the default template used by all pages unless another specific template is selected for a specific page. And site templates may be present but unused. </translate>


Newcomers to Joomla, sometimes new to PHP too, may know little of the architecture of a Joomla web site and how it all comes together to present a web site to the end user. That was me in 2010! However, having arrived here you will realise that Cassiopeia is a Site Template that controls the appearance of a site as seen by the general public. Administrators use a different template, Atum, with a completely different appearance. These templates are sometimes referred to as front-end and back-end templates.
<translate>
<!--T:4-->
This tutorial explains the use of the various files in the default Cassiopeia site template.</translate>


A template is a Joomla extension that consists of a collection of files that take care of different aspects of the presentation. A web-site may have a number of site templates, one of which must be chosen as the default template used by all pages unless another specific template is selected for a specific page. And site templates may be present but unused.
<translate>
== Changes from Joomla 4.0 to Joomla 4.1 == <!--T:5--></translate>


This tutorial explains the use of the various files in a the default Cassiopeia site template.  
Joomla 4.1 has moved the default media files from the templates folder to the media/templates folder. Existing media folders are moved on upgrade.


== File Structure ==
<translate>
== File Structure == <!--T:6--></translate>


The following illustration shows the folder structure of the Cassiopeia template, including the files in the template root.
<translate>
<!--T:7-->
The following illustration shows the folder structure of the Cassiopeia template, including the files in the template root.</translate>


[[File:j4x-cassiopeia_template_explained_file_structure.png|File Structure]]
{| class="wikitable"
|-
! Joomla 4.0 !! Joomla 4.1
|-
| [[File:j4x-cassiopeia_template_explained_file_structure.png|<translate><!--T:8--> Joomla 4.0 File Structure</translate>]] || [[File:j4x-cassiopeia_template_explained_file_structure_41.png|<translate><!--T:9--> Joomla 4.1 File Structure</translate>]]
|}


<translate>
<!--T:10-->
A lot to explain! A brief starter explanation:
A lot to explain! A brief starter explanation:


* css - the folder containing all of the template css files
<!--T:11-->
* css - the folder containing all of the template CSS files
* html - a folder containing component and module overrides, which may be empty
* html - a folder containing component and module overrides, which may be empty
* images - a folder for images used by the template and its styles
* images - a folder for images used by the template and its styles
* js - a folder for javascript used by the template
* js - a folder for JavaScript used by the template
* scss - a folder for the scss files compiled to make the css files
* scss - a folder for the scss files compiled to make the CSS files
* component.php - a layout used to display just a component without surrounding modules
* component.php - a layout used to display just a component without surrounding modules
* error.php - a simple layout used to display errors when a normal page cannot be displayed
* error.php - a simple layout used to display errors when a normal page cannot be displayed
* index.php - the layout used for all site pages using this template
* index.php - the layout used for all site pages using this template
* joomla.asset.json - a file specifying where to find css and js resources
* joomla.asset.json - a file specifying where to find CSS and JavaScript resources
* offline.php - a layout used to show a site is off-line for maintenace
* offline.php - a layout used to show a site is off-line for maintenance
* template_preview.php and template_details.php - images used for administration
* template_preview.php and template_details.php - images used for administration
* templateDetails.xml - the extension specification used for installation
* templateDetails.xml - the extension specification used for installation</translate>


<translate>
<!--T:12-->
Where to start?
Where to start?


== index.php ==
== ''index.php'' == <!--T:13-->


You are probably aware that a very simple html page looks like this:
<!--T:14-->
You are probably aware that a very simple HTML page looks like this:</translate>


<source lang="php">
<translate>
<!--T:15-->
<syntaxhighlight lang="php">
<html>
<html>
<head>
<head>
Line 45: Line 72:
</body>
</body>
</html>
</html>
</source>
</syntaxhighlight></translate>


That is what is in index.php except that it is a little more complicated. Have a look through the file with a text editor and not the following:
<translate>
<!--T:16-->
That is what is in index.php except that it is a little more complicated. Have a look through the file with a text editor and note the following:


* The first executable statement is '''defined('_JEXEC') or die;''' - every Joomla php file starts like that to prevent calling directly via an absolute url. _JEXEC is defined when a page is accessed via https://domain/[site-root/]index.php (usually with index.php left off as that is used by default).
<!--T:17-->
* The actual html output starts with '''<!DOCTYPE html>''' on line 127 - everything before that is php code to set needed variables.
* The first executable statement is '''defined('_JEXEC') or die;''' - every Joomla PHP file starts like that to prevent calling directly via an absolute URL. _JEXEC is defined when a page is accessed via mydomain.com/[site-root/]index.php (usually with index.php left off as that is used by default).
* The head and the body contain jdoc statements that cause insertion of specific types of content - more on that later.
* The actual HTML output starts with '''<!DOCTYPE html>''' on line 127 - everything before that is PHP code to set needed variables.
* The head and the body contain '''jdoc:include''' statements that cause insertion of specific types of content - more on that later.
* The body contains landmarks such as header, main, and footer - accessibility features.
* The body contains landmarks such as header, main, and footer - accessibility features.
* The overall layout is achieved with grids - included only where the grid positions actually include modules.
* The overall layout is achieved with grids - included only where the grid positions actually include modules.</translate>


=== Favicons ===
<translate>
=== Favicons === <!--T:18-->
Favicons are the small icons that appear in the browser tab alongside your site name. Near the top of index.php are three instructions to load favicons into the page:</translate>


Favicons are the small icons that appear in the browser tab alongside your site name. Near the top of index.php are three instructions to load favicons into the page:
<syntaxhighlight lang="php">
<source lang="php">
// Browsers support SVG favicons
// Browsers support SVG favicons
$this->addHeadLink(HTMLHelper::_('image', 'joomla-favicon.svg', '', [], true, 1), 'icon', 'rel', ['type' => 'image/svg+xml']);
$this->addHeadLink(HTMLHelper::_('image', 'joomla-favicon.svg', '', [], true, 1), 'icon', 'rel', ['type' => 'image/svg+xml']);
$this->addHeadLink(HTMLHelper::_('image', 'favicon.ico', '', [], true, 1), 'alternate icon', 'rel', ['type' => 'image/vnd.microsoft.icon']);
$this->addHeadLink(HTMLHelper::_('image', 'favicon.ico', '', [], true, 1), 'alternate icon', 'rel', ['type' => 'image/vnd.microsoft.icon']);
$this->addHeadLink(HTMLHelper::_('image', 'joomla-favicon-pinned.svg', '', [], true, 1), 'mask-icon', 'rel', ['color' => '#000']);
$this->addHeadLink(HTMLHelper::_('image', 'joomla-favicon-pinned.svg', '', [], true, 1), 'mask-icon', 'rel', ['color' => '#000']);
</source>
</syntaxhighlight>


Joomla will look for the favicons first in cassiopeia/images - they are not there so Joomla will look in media/system/images - so Joomla will load the urls for the images there. If you want to use your own favicons rather than Joomla favicons you upload them to cassiopeia/images. They will not be affected by any update to the cassiopeia template.
<translate>
<!--T:19-->
Joomla will look for the favicons first in media/templates/cassiopeia/images - they are not there so Joomla will look in media/system/images - they are there so Joomla will load the URLs for the images there. If you want to use your own favicons rather than Joomla favicons you upload them to media/templates/cassiopeia/images. You can do that using the Templates: Customise form. They will not be affected by any update to the Cassiopeia template.</translate>


=== Template Variables ===
<translate>
=== Template Variables === <!--T:20-->
If you look through the template you will find lines containing $this->params->get(...) like this one:</translate>


If you look through the template you will find lines containing $this->params->get(...) like this one:


<source lang="php">
<syntaxhighlight lang="php">
$paramsColorName = $this->params->get('colorName', 'colors_standard');
$paramsColorName = $this->params->get('colorName', 'colors_standard');
</source>
</syntaxhighlight>


Those parameters are set in the Advance tab of the Template: Edit Style page. That is where you can change the brand, logo, colour, layout, etc. The variables are defined in the templateDetails.xml file.
<translate>
<!--T:21-->
Those parameters are set in the Advance tab of the Template: Edit Style page. That is where you can change the brand, logo, colour, layout, etc. The variables are defined in the templateDetails.xml file.</translate>


=== The Web Asset Manager ===
<translate>
=== The Web Asset Manager === <!--T:22-->
Notice the line near the top of index.php that creates an instance of the web asset manager and later lines that use it:</translate>


Notice the line near the top of index.php that creates an instance of the web asset manager and later lines that use it:
<syntaxhighlight lang="php">
 
$wa = $this->getWebAssetManager();
<source lang="php">
$this->params->get
...
...
$wa->registerAndUseStyle($assetColorName, $templatePath . '/css/global/' . $paramsColorName . '.css');
$wa->registerAndUseStyle($assetColorName, $templatePath . '/css/global/' . $paramsColorName . '.css');
</source>
</syntaxhighlight>


Joomla uses information in joomla.asset.json to load assets needed by the template. A portion of that file is shown here:
<translate>
<!--T:23-->
Joomla uses information in joomla.asset.json to load assets needed by the template. A portion of that file is shown here:</translate>


<source lang="php">
<syntaxhighlight lang="php">
{
{
   "$schema": "https://developer.joomla.org/schemas/json-schema/web_assets.json",
   "$schema": "https://developer.joomla.org/schemas/json-schema/web_assets.json",
Line 106: Line 144:
       ]
       ]
     },
     },
</source>
</syntaxhighlight>
 
It shows that the asset named template.cassiopeia.ltr is to be found in in css/template.min.css and that asset in turn requires fontawesome, defined at the end of joomla.assets.json. Note that if you switch to debug mode joomla will load the versions of css and js without the .min part.
 
=== The jdoc Statements ===


At some point during page creation the template index.php file is parsed (analysed) by the Joomla code and the jdoc statements picked out in reverse order. The html outputs of each then replace the lines containing those jdoc statements. Amonst other things, that puts module contents into the page. Page ready for output?
<translate>
<!--T:24-->
It shows that the asset named template.cassiopeia.ltr is to be found in in css/template.min.css and that asset in turn requires fontawesome, defined at the end of joomla.assets.json. Note that if you switch to debug mode, Joomla will load the versions of CSS and JavaScript without the .min part.</translate>


== The css Files ==
<translate>
=== The ''jdoc'' Statements === <!--T:25-->
At some point during page creation the template index.php file is parsed (analysed) by the Joomla code and the jdoc statements picked out in reverse order. Each jdoc statement leads to code to generate a block of HTML to replace that statement. Amongst other things, that puts module content into the page.</translate>


The css folder contains the css files used by the cassiopeia template. It is worth noting the file sizes of the different variants of a single css style sheet. For example template.css has these varieties:
<translate>
== The CSS Files == <!--T:26-->
The ''css'' folder contains the CSS files used by the Cassiopeia template. It is worth noting the file sizes of the different variants of a single CSS style sheet. For example ''template.css'' has these varieties:</translate>


<translate>
<!--T:27-->
* template.css 258,272 bytes
* template.css 258,272 bytes
* template.min.css 205,427 bytes
* template.min.css 205,427 bytes
* template.min.css.gz 32,526 butes
* template.min.css.gz 32,526 bytes</translate>


The first, template.css is a human readable variant that is used when system debugging is enabled. The second, template.min.css is used on production sites where debugging is disabled. It has all white space removed and some optimisations made. The third, template.min.css.gz is a gzip compressed variant of the min version used if the site .htaccess file is set up to offer gzip variants of static resources. There is an article describing how do this in the [https://magazine.joomla.org/all-issues/december-2021/joomla-performance-tuning-ii-basic-settings Community Magazine].
<translate>
<!--T:28-->
The first, template.css is a human-readable variant that is used when system debugging is enabled. The second, template.min.css is used on production sites where debugging is disabled. It has all white space removed and some optimisations made. The third, template.min.css.gz is a Gzip compressed variant of the min version used if the site ''.htaccess'' file is set up to offer Gzip variants of static resources. There is an article describing how do this in the [https://magazine.joomla.org/all-issues/december-2021/joomla-performance-tuning-ii-basic-settings Community Magazine].</translate>


=== user.css ===
<translate>
<!--T:29-->
Clearly the ''gz'' version is the most network bandwidth friendly.</translate>


Absent from the initial list of css files is user.css. This is a file that you create yourself to contain additions and overrides to the existing styles. For example, module parameters typically include a Module Class text entry box in the Advanced tab. Any module class you add there should have an entry in user.css. If you wish to override an existing style you can make an entry like this:
<translate>
=== ''user.css'' === <!--T:30-->
Absent from the initial list of CSS files is user.css. This is a file that you create yourself to contain additions and overrides to the existing styles. For example, module parameters typically include a Module Class text entry box in the Advanced tab. Any module class you add there should have an entry in user.css. If you wish to override an existing style you can make an entry like this:</translate>


<source lang="php">
 
<syntaxhighlight lang="php">
h1, .h1 {
h1, .h1 {
   color: purple;
   color: purple;
}
}
</source>
</syntaxhighlight>
 
== The html Files ==
 
This is the place to keep component and module template overrides. For example, when Joomla renders a module it first looks for a template here and then in the modules own tmpl folder. This allows you to override the appearance of a core Joomla module or a third party extension module without changing the original code. Any changes made there would be overwritten by an update.
 
The default cassiopeia template comes with overrides for overrides, mod_custom, mod_menu and tinymce.


== The js Files ==
<translate>
== The HTML Files == <!--T:31-->
This is the place to keep module, component, plugin and layout template overrides. For example, when Joomla renders a module it first looks for a template here and then in the modules own tmpl folder. This allows you to override the appearance of a core Joomla extension or a third party extension without changing the original code. Any changes made there would be overwritten by an update.


There is only one basic javascript file used by the template and like css it comes in three varieties: template.css, template.min.css and template.min.css.gz. There is one other variety of interest: template.es5.js, which is coded for EcmaScript 5 (the 2011 version). All of the other javascript files are coded for later EcmaScript versions.  
<!--T:32-->
The default Cassiopeia template comes with overrides for layouts, mod_custom, mod_menu and tinymce.</translate>


EcmaScript is currently up to Version 12 but it takes a while for browsers to catch up and adopt a new standard. Javascript is a synonym for EcmaScript. See [https://en.wikipedia.org/wiki/ECMAScript Wikipedia] for a summary.


== The scss Files ==
<translate>
== The JavaScript Files == <!--T:33-->
There is only one basic JavaScript file used by the template and like CSS it comes in three varieties: template.js, template.min.js and template.min.js.gz. There is one other variety of interest: template.es5.js, which is coded for EcmaScript 5 (the 2011 version). All of the other JavaScript files are coded for later EcmaScript versions. </translate>


The scss files contain the sources used to create the css files. They need to be compiled with a third party compiler. More...
<translate>
<!--T:34-->
EcmaScript is currently up to Version 12 but it takes a while for browsers to catch up and adopt a new standard. JavaScript is a synonym for EcmaScript. See [https://en.wikipedia.org/wiki/ECMAScript Wikipedia] for a summary.</translate>


== Template Positions ==
<translate>
== The SCSS Files == <!--T:35-->
The SCSS files contain the sources used to create the CSS files. They need to be compiled with a third party compiler. More...</translate>


The positions in which modules can be placed are named in the templateDetails.xml file:
<translate>
== Template Positions == <!--T:36-->
The positions in which modules can be placed are named in the templateDetails.xml file:</translate>


<source lang="xml">
<syntaxhighlight lang="xml">
<positions>
<positions>
<position>topbar</position>
<position>topbar</position>
Line 173: Line 226:
<position>debug</position>
<position>debug</position>
</positions>
</positions>
</source>
</syntaxhighlight>
 
<translate>
<!--T:37-->
The following illustration shows in schematic form where those positions occur on the page:</translate>
 
<translate>
<!--T:38-->
[[File:j4x-cassiopeia_template_explained_positions.png|Template Positions]]</translate>
 
<translate>
<!--T:39-->
Notice the '''component''' position marked with a green background. That is where the output from a component view is placed and is often the largest portion of the page. Immediately above that is the message position where Joomla system messages appear. For example, ''Your changes have been saved''.</translate>
 
<translate>
<!--T:40-->
The illustration shows that some of the positions are within landmarks such as '''header''' and '''footer''' but others are not. Something to look into! </translate>
 
<translate>
<!--T:41-->
With the sample data installed, the following illustration shows the Home page landmarks in the browser tools '''Inspector''' view.
</translate>
 
<translate>
<!--T:42-->
[[File:j4x-cassiopeia_template_explained_inspector_landmarks.png|Template Landmarks]]</translate>
 
<translate>
<!--T:43-->
The header contains a '''brand''' location, not a position to which a module can be assigned. It can be left out. Beneath that is a '''menu''' and/or '''search''' position. It is used for the site menu and search box.</translate>


The following illustration shows in schematic form where those positions occur on the page:


[[File:j4x-cassiopeia_template_explained_positions.png|Template Positions]]
<translate>
<!--T:44-->
The contents of the remaining divs are self-evident from their class names. There is no container-sidebar-left because the sample data does not assign any module to that position.</translate>


Notice the '''component''' position marked with a green background. That is where the output from a component view is placed and is often the largest portion of the page. Immediately above that is the message position where Joomla system messages appear. For exampls, ''Your changes have been saved''.


Aaargh! Forgot to show the debug position which is below the footer position. The illustration shows that some of the positions are within landmarks such as '''header''' and '''footer''' but others are not. Something to look into! The following illustration shows the landmarks in the browser tools '''Inspector''' view.
<translate>
== Further Information == <!--T:45-->
* [[J4.x:Cassiopeia Template Customisation|Cassiopeia Template Customisation]] - using the Edit Style form and user.css
* [[J4.x:Cassiopeia Template Simplified - A Case Study|Cassiopeia Template Simplified - A Case Study]] - a simple template based on Cassiopeia</translate>


[[File:j4x-cassiopeia_template_explained_inspector_landmarks.png|Template Landmarks]]
<noinclude>
[[Category:Tutorials{{#translation:}}]]
[[Category:Joomla! 4.x{{#translation:}}]]
</noinclude>

Latest revision as of 11:13, 7 June 2024

Joomla! 
4.x

Introduction

Newcomers to Joomla, sometimes new to PHP too, may know little of the architecture of a Joomla website and how it all comes together to present a website to the end user. That was me in 2010! However, having arrived here you will realise that Cassiopeia is a Site Template that controls the appearance of a site as seen by the general public. Administrators use a different template, Atum, with a completely different appearance. These templates are sometimes referred to as Frontend and Backend templates.

A template is a Joomla extension that consists of a collection of files that take care of different aspects of the presentation. A website may have a number of site templates, one of which must be chosen as the default template used by all pages unless another specific template is selected for a specific page. And site templates may be present but unused.

This tutorial explains the use of the various files in the default Cassiopeia site template.

Changes from Joomla 4.0 to Joomla 4.1

Joomla 4.1 has moved the default media files from the templates folder to the media/templates folder. Existing media folders are moved on upgrade.

File Structure

The following illustration shows the folder structure of the Cassiopeia template, including the files in the template root.

Joomla 4.0 Joomla 4.1
Joomla 4.0 File Structure Joomla 4.1 File Structure

A lot to explain! A brief starter explanation:

  • css - the folder containing all of the template CSS files
  • html - a folder containing component and module overrides, which may be empty
  • images - a folder for images used by the template and its styles
  • js - a folder for JavaScript used by the template
  • scss - a folder for the scss files compiled to make the CSS files
  • component.php - a layout used to display just a component without surrounding modules
  • error.php - a simple layout used to display errors when a normal page cannot be displayed
  • index.php - the layout used for all site pages using this template
  • joomla.asset.json - a file specifying where to find CSS and JavaScript resources
  • offline.php - a layout used to show a site is off-line for maintenance
  • template_preview.php and template_details.php - images used for administration
  • templateDetails.xml - the extension specification used for installation

Where to start?

index.php

You are probably aware that a very simple HTML page looks like this:

<html>
<head>
</head>
<body>
<h1>Hello World!</h1>
<p>Message of the day.</p>
</body>
</html>

That is what is in index.php except that it is a little more complicated. Have a look through the file with a text editor and note the following:

  • The first executable statement is defined('_JEXEC') or die; - every Joomla PHP file starts like that to prevent calling directly via an absolute URL. _JEXEC is defined when a page is accessed via mydomain.com/[site-root/]index.php (usually with index.php left off as that is used by default).
  • The actual HTML output starts with <!DOCTYPE html> on line 127 - everything before that is PHP code to set needed variables.
  • The head and the body contain jdoc:include statements that cause insertion of specific types of content - more on that later.
  • The body contains landmarks such as header, main, and footer - accessibility features.
  • The overall layout is achieved with grids - included only where the grid positions actually include modules.

Favicons

Favicons are the small icons that appear in the browser tab alongside your site name. Near the top of index.php are three instructions to load favicons into the page:

// Browsers support SVG favicons
$this->addHeadLink(HTMLHelper::_('image', 'joomla-favicon.svg', '', [], true, 1), 'icon', 'rel', ['type' => 'image/svg+xml']);
$this->addHeadLink(HTMLHelper::_('image', 'favicon.ico', '', [], true, 1), 'alternate icon', 'rel', ['type' => 'image/vnd.microsoft.icon']);
$this->addHeadLink(HTMLHelper::_('image', 'joomla-favicon-pinned.svg', '', [], true, 1), 'mask-icon', 'rel', ['color' => '#000']);

Joomla will look for the favicons first in media/templates/cassiopeia/images - they are not there so Joomla will look in media/system/images - they are there so Joomla will load the URLs for the images there. If you want to use your own favicons rather than Joomla favicons you upload them to media/templates/cassiopeia/images. You can do that using the Templates: Customise form. They will not be affected by any update to the Cassiopeia template.

Template Variables

If you look through the template you will find lines containing $this->params->get(...) like this one:


$paramsColorName = $this->params->get('colorName', 'colors_standard');

Those parameters are set in the Advance tab of the Template: Edit Style page. That is where you can change the brand, logo, colour, layout, etc. The variables are defined in the templateDetails.xml file.

The Web Asset Manager

Notice the line near the top of index.php that creates an instance of the web asset manager and later lines that use it:

$wa = $this->getWebAssetManager();
...
$wa->registerAndUseStyle($assetColorName, $templatePath . '/css/global/' . $paramsColorName . '.css');

Joomla uses information in joomla.asset.json to load assets needed by the template. A portion of that file is shown here:

{
  "$schema": "https://developer.joomla.org/schemas/json-schema/web_assets.json",
  "name": "cassiopeia",
  "version": "4.0.0",
  "description": "This file contains details of the assets used by Cassiopeia, the default Joomla 4 site template.",
  "license": "GPL-2.0-or-later",
  "assets": [
    {
      "name": "template.cassiopeia.ltr",
      "description": "The css file to be used when the site is left to right (LTR).",
      "type": "style",
      "uri": "template.min.css",
      "dependencies": [
        "fontawesome"
      ]
    },

It shows that the asset named template.cassiopeia.ltr is to be found in in css/template.min.css and that asset in turn requires fontawesome, defined at the end of joomla.assets.json. Note that if you switch to debug mode, Joomla will load the versions of CSS and JavaScript without the .min part.

The jdoc Statements

At some point during page creation the template index.php file is parsed (analysed) by the Joomla code and the jdoc statements picked out in reverse order. Each jdoc statement leads to code to generate a block of HTML to replace that statement. Amongst other things, that puts module content into the page.

The CSS Files

The css folder contains the CSS files used by the Cassiopeia template. It is worth noting the file sizes of the different variants of a single CSS style sheet. For example template.css has these varieties:

  • template.css 258,272 bytes
  • template.min.css 205,427 bytes
  • template.min.css.gz 32,526 bytes

The first, template.css is a human-readable variant that is used when system debugging is enabled. The second, template.min.css is used on production sites where debugging is disabled. It has all white space removed and some optimisations made. The third, template.min.css.gz is a Gzip compressed variant of the min version used if the site .htaccess file is set up to offer Gzip variants of static resources. There is an article describing how do this in the Community Magazine.

Clearly the gz version is the most network bandwidth friendly.

user.css

Absent from the initial list of CSS files is user.css. This is a file that you create yourself to contain additions and overrides to the existing styles. For example, module parameters typically include a Module Class text entry box in the Advanced tab. Any module class you add there should have an entry in user.css. If you wish to override an existing style you can make an entry like this:


h1, .h1 {
  color: purple;
}

The HTML Files

This is the place to keep module, component, plugin and layout template overrides. For example, when Joomla renders a module it first looks for a template here and then in the modules own tmpl folder. This allows you to override the appearance of a core Joomla extension or a third party extension without changing the original code. Any changes made there would be overwritten by an update.

The default Cassiopeia template comes with overrides for layouts, mod_custom, mod_menu and tinymce.


The JavaScript Files

There is only one basic JavaScript file used by the template and like CSS it comes in three varieties: template.js, template.min.js and template.min.js.gz. There is one other variety of interest: template.es5.js, which is coded for EcmaScript 5 (the 2011 version). All of the other JavaScript files are coded for later EcmaScript versions.

EcmaScript is currently up to Version 12 but it takes a while for browsers to catch up and adopt a new standard. JavaScript is a synonym for EcmaScript. See Wikipedia for a summary.

The SCSS Files

The SCSS files contain the sources used to create the CSS files. They need to be compiled with a third party compiler. More...

Template Positions

The positions in which modules can be placed are named in the templateDetails.xml file:

	<positions>
		<position>topbar</position>
		<position>below-top</position>
		<position>menu</position>
		<position>search</position>
		<position>banner</position>
		<position>top-a</position>
		<position>top-b</position>
		<position>main-top</position>
		<position>main-bottom</position>
		<position>breadcrumbs</position>
		<position>sidebar-left</position>
		<position>sidebar-right</position>
		<position>bottom-a</position>
		<position>bottom-b</position>
		<position>footer</position>
		<position>debug</position>
	</positions>

The following illustration shows in schematic form where those positions occur on the page:

Template Positions

Notice the component position marked with a green background. That is where the output from a component view is placed and is often the largest portion of the page. Immediately above that is the message position where Joomla system messages appear. For example, Your changes have been saved.

The illustration shows that some of the positions are within landmarks such as header and footer but others are not. Something to look into!

With the sample data installed, the following illustration shows the Home page landmarks in the browser tools Inspector view.

Template Landmarks

The header contains a brand location, not a position to which a module can be assigned. It can be left out. Beneath that is a menu and/or search position. It is used for the site menu and search box.


The contents of the remaining divs are self-evident from their class names. There is no container-sidebar-left because the sample data does not assign any module to that position.


Further Information