Page view's TPL files "classic" structure

Default directory for page views is hidden/tpl/pages/. Simple sites that have few pages and don't require multilanguage support can store all of their TPL files in this dir. Tangra framework based sites are meant to be bigger and with a lot of functionality. That is the reason classic TPL files structure to be a bit more complicated in order to support multilanguage and thematic grouping. Please note that classic structure is not mandatory - you may use whatever structure you see fit.

Classic TPL files structure is (here we will suppose that site's default language is english (en)):

Let's take closer look at template_en.tpl. By default when Jabba site template is installed it contains:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="{$_base_url}" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My site - {include file="`$_path``$_language`/`$_subdir``$_page`/`$_page`_title_`$_language`.tpl"}</title>

{foreach from=$_additional_csses item=_css}
<link rel="stylesheet" type="text/css" href="/css/{$_css}" />
{/foreach}
</head>
<body>
{if $_page != 'index'}<h1>{include file="`$_path``$_language`/`$_subdir``$_page`/`$_page`_title_`$_language`.tpl"}</h1>{/if}
{include file="`$_path``$_language`/`$_subdir``$_page`/`$_page`_`$_view`_`$_language`.tpl"}
</body>
</html>
                
            

Above you can see that *title_en.tpl is included two times - first in the TITLE tag and then in H1 tag. That way you avoid duplication of text. Here is schematic representation of classic structure:

Figure 10.1. Classic structure

Classic structure

It is not mandatory that you use exactly that scheme for template_??.tpl. For example you can use different titles for TITLE and H1 by including different TPL files like this:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="{$_base_url}" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My site - {include file="`$_path``$_language`/`$_subdir``$_page`/`$_page`_title_head_`$_language`.tpl"}</title>

{foreach from=$_additional_csses item=_css}
<link rel="stylesheet" type="text/css" href="/css/{$_css}" />
{/foreach}
</head>
<body>
{if $_page != 'index'}<h1>{include file="`$_path``$_language`/`$_subdir``$_page`/`$_page`_title_content_`$_language`.tpl"}</h1>{/if}
{include file="`$_path``$_language`/`$_subdir``$_page`/`$_page`_`$_view`_`$_language`.tpl"}
</body>
</html>
                
            

In above example TPL files for TITLE tag will have to be named *_title_head_en.tpl and files for content area *_title_content_en.tpl.

template_??.tpl files can become large too. It such cases it is recommendable to split them. For example you may want to create separate files for header, footer, main menu, etc.