I’m trying to use the $template->name by declaring this in "_init.php":
$cssFile = $template->name . ".css";
… and I then have this in "_main.php":
// Use custom CSS-file if that file exists.
<?php if(is_file($config->paths->templates . "styles/$cssFile")) {
echo "<link rel='stylesheet' type='text/css' href='{$config->urls->templates}styles/$cssFile' />";
}; ?>
However PW throws this notice:
Notice: Undefined variable: template in /Users/claus/Sites/ProcessWire/site/templates/_init.php on line 29
Notice: Trying to get property of non-object in /Users/claus/Sites/ProcessWire/site/templates/_init.php on line 29
// Use custom CSS-file if that file exists.
Do I have to define $template->name? I thought that was a built-in function?