contao/issues — Issue #772: Multiple frontend template specifiable by layout
Author: importer
Created: 2011-11-24 16:00:28+00:00
State: open
Labels: Feature, frontend

Hi Leo,

Currently to manage multiple sites in typolight it's not possible to specify different templates, but just a different css for each page layout.
I suggest to adding a drop down field in the "Page Layout" menu, with a list of themes (similar to how the backend works already, but also for .tpl files), so that you can define .tpl files specific to each individual site (eg for menage multiple sites with many layout difference).

The structure would be:

/templates
/templates/theme1
/templates/theme2

This could be done by modifying the function getTemplate($strTemplate) in the file Controller.php for seeking if $strTemplate
is present in the selected theme directory (eg: /templates/$frontendTheme) before seeking in /templates

The function could become (/system/libraries/Controller.php):

```
/**
* Find a particular template file and return its path
* `param string
* `return string
* @throws Exception
*/
protected function getTemplate($strTemplate)
{
//NEW: find template in current frontend theme
if( $GLOBALS['frontendTheme'] != null ){
$strFile = sprintf('%s/themes/%s/templates/%s.tpl', TL_ROOT, $GLOBALS['frontendTheme'], $strTemplate);

if (file_exists($strFile)){
return $strFile;
}
}
////NEW: end - find template in current frontend theme

$strFile = sprintf('%s/templates/%s.tpl', TL_ROOT, $strTemplate);

if (!file_exists($strFile))
{
foreach ($this->Config->getActiveModules() as $strModule)
{
$strPath = sprintf('%s/system/modules/%s/templates/%s.tpl', TL_ROOT, $strModule, $strTemplate);

if (file_exists($strPath))
{
$strFile = $strPath;
break;
}
}
}

if (!file_exists($strFile))
{
throw new Exception(sprintf('Could not find template file "%s"', $strTemplate));
}

return $strFile;
}
```

In attachment, a screenshot of backend Page layout new field.

[Download the attachments](http://www.contao.org/tl_files/tickets/772.zip "Download the attachments of this ticket")

--- _Originally created by dennisforrest on June 4th, 2009, at 12:46pm (ID 772)_