Override login form from theme
Copied from this forum post, so we're tracking this issue in the right place (an issue).
Summary
We can override other templates in other modules by simply placing .htm templates in interface/web/themes/mytheme/templates/modulename/template-to-override.htm However since the login page is not a module, ISPConfig doesn't bother to look inside my theme's templates/login directory. The templates I want to customize there are login/index.htm, login/otp.htm and login/password_reset.htm
Instead it appears (looking at the source-code) that the _fileSearch method in interface/lib/classes/tpl.inc.php:
- Passes by the first guard as isset($_SESSION['s']['module']['name']) is false on the login page
- Matches the full path, because web/login/index.php looks for $app->tpl->setInclude('content_tpl', 'templates/index.htm'); and finds that relative to the interface/web/ directory
Naive fix
// inside _fileSearch in lib/classes/tpl.inc.php
$modulename = false;
if(isset($_SESSION['s']['module']['name'])) {
$modulename = $_SESSION['s']['module']['name'];
} elseif(strpos($_SERVER['PHP_SELF'], '/login/') === 0) {
$modulename = 'login';
}
if($modulename && isset($_SESSION['s']['theme'])) {
if(is_file(ISPC_THEMES_PATH.'/'.$_SESSION['s']['theme'].'/templates/'.$modulename.'/'.$filename)) {
return ISPC_THEMES_PATH.'/'.$_SESSION['s']['theme'].'/templates/'.$modulename.'/'.$filename;
}
}
I'll double-check the contribution guidelines and code conventions to see if the above fix will suffice. Furthermore I'll make a list of the pages I tested after applying the fix.
I'll be picking up this issue sometime before the end of this Wednesday, submitting a PR that closes this issue.