For this problem has tens/ hundreds maybe even thousands of possible solutions. I will post a structure that I used.
Structure
\
|__ Templates\
| |__ Default\
| | |__ css\
| | |__ js\
| | |__ img\
| | |__ index.php
| |
| |__ Dark\
| | |__ css\
| | |__ js\
| | |__ img\
| | |__ index.php
| |
| |__ Light\
| |__ css\
| |__ js\
| |__ img\
| |__ index.php
|
|__ Pages\
| |__ home.php
| |__ contato.php
| |__ sobre.php
| |__ 404.php
|
|__ index.php /* Código do arquivo abaixo */
|__ menu.php
index php.
define('TITULO', 'Site com vários templates');
$page = (!empty($_GET['page']) $_GET['page'] : 'home';
if (file_exists(__DIR__.'\\pages\\'.$page.'php'))
define('PAGE' file_exists(__DIR__.'\\pages\\'.$page.'php'));
else
define('PAGE', __DIR__.'\\pages\\404.php');
define('MENU', __DIR__.'\\menu.php');
// Este valor pode ser recebido do banco de dados, ou de algum arquivo de configuração
$template = "Default";
require_once __DIR__.'\\Templates\\'.$template.'\\index.php';
Templates files
In each file index.php
of each template you must have your HTML code and files like CSS and Javascript must be re-referenced with absolute path, for example:
<!DOCTYPE html>
<html>
<head>
<title><?=TITULO?></title>
<link rel="stylesheet" type="text/css" href="http://meudominio.com/Templates/Default/estilos.css">
<script src="http://meudominio.com/Templates/Default/arquivo.js"></script>
</head>
<body>
<?php
require_once MENU;
require_once PAGE;
?>
</body>
</html>
If I understood correctly, at include time, you consult the bank, read the resource and use the stored value as part of the path inclusion.
– Bruno Augusto
That’s right, simple as that...
– Mauricio Mendez