fixed some bugs
This commit is contained in:
parent
ea40fc8e38
commit
713a44ad98
@ -34,7 +34,12 @@ class Router {
|
|||||||
private function setRouteFile() {
|
private function setRouteFile() {
|
||||||
foreach ($this->routes as $key => $value) {
|
foreach ($this->routes as $key => $value) {
|
||||||
if ( $this->path == $key) {
|
if ( $this->path == $key) {
|
||||||
$this->controllerPath = BASEPATH . '/App/controllers/' . $value['file'] . '.php';
|
$theFile = BASEPATH . '/App/controllers/' . $value['file'] . '.php';
|
||||||
|
|
||||||
|
//check if the file exists
|
||||||
|
if (file_exists($theFile)) {
|
||||||
|
$this->controllerPath = $theFile;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,22 @@
|
|||||||
require_once(BASEPATH . '/vendor/autoload.php');
|
require_once(BASEPATH . '/vendor/autoload.php');
|
||||||
|
|
||||||
//Twig
|
//Twig
|
||||||
$loader = new Twig\Loader\FilesystemLoader(BASEPATH . '/App/views/');
|
function view($name = '', $data = [] ) {
|
||||||
$loader->addPath(BASEPATH . '/vendor/4lt/novaconium/twig', 'novaconium');
|
$loader = new Twig\Loader\FilesystemLoader(BASEPATH . '/App/views/');
|
||||||
$loader->addPath(BASEPATH . '/App/templates', 'override');
|
$loader->addPath(BASEPATH . '/vendor/4lt/novaconium/twig', 'novaconium');
|
||||||
$twig = new Twig\Environment($loader);
|
$loader->addPath(BASEPATH . '/App/templates', 'override');
|
||||||
|
$twig = new Twig\Environment($loader);
|
||||||
|
//check if file exists
|
||||||
|
if (file_exists(BASEPATH . '/App/views/' . $name . '.html.twig')) {
|
||||||
|
echo $twig->render("$name" . '.html.twig', $data);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
echo "Error: Twig Template ($name) Not Found.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Load a controller
|
// Load a controller
|
||||||
require_once('Router.php');
|
require_once('Router.php');
|
||||||
$router = new Router();
|
$router = new Router();
|
||||||
require_once($router->controllerPath);
|
require_once($router->controllerPath);
|
||||||
|
@ -8,45 +8,45 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body id="{{ pageid | default('pageid') }}">
|
<body id="{{ pageid | default('pageid') }}">
|
||||||
|
|
||||||
|
{# Page Header #}
|
||||||
|
<header>
|
||||||
|
{% block headerbefore %}{% endblock %}
|
||||||
|
{% include ['@override/nav.html.twig', '@novaconium/nav.html.twig'] %}
|
||||||
|
{% block headerafter %}{% endblock %}
|
||||||
|
</header>
|
||||||
|
|
||||||
{# Page Header #}
|
<!-- Main Content Of The Page -->
|
||||||
<header>
|
<div id="page">
|
||||||
{% block headerbefore %}{% endblock %}
|
<div class="container">
|
||||||
{% include ['@override/nav.html.twig', '@novaconium/nav.html.twig'] %}
|
|
||||||
{% block headerafter %}{% endblock %}
|
|
||||||
</header>
|
|
||||||
|
|
||||||
<!-- Main Content Of The Page -->
|
<div class="middle">
|
||||||
<div id="page">
|
{% if error|default is not empty %}
|
||||||
<div class="container">
|
{% for key, val in error %}
|
||||||
|
<div class="error">{{ val }}</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<div class="middle">
|
{% if notice|default is not empty %}
|
||||||
{% if error|default is not empty %}
|
{% for key, val in notice %}
|
||||||
{% for key, val in error %}
|
<div class="notice">{{ val }}</div>
|
||||||
<div class="error">{{ val }}</div>
|
{% endfor %}
|
||||||
{% endfor %}
|
{% endif %}
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if notice|default is not empty %}
|
<article>
|
||||||
{% for key, val in notice %}
|
{% block content %}{% endblock %}
|
||||||
<div class="notice">{{ val }}</div>
|
</article>
|
||||||
{% endfor %}
|
</div>
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<article>
|
|
||||||
{% block content %}{% endblock %}
|
|
||||||
</article>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
{# Page Footer #}
|
|
||||||
<footer>
|
|
||||||
{% block footerbefore %}{% endblock %}
|
|
||||||
{% include ['@override/footer.html.twig', '@novaconium/footer.html.twig'] %}
|
|
||||||
{% block footerafter %}{% endblock %}
|
|
||||||
</footer>
|
|
||||||
|
|
||||||
|
{# Page Footer #}
|
||||||
|
<footer>
|
||||||
|
{% block footerbefore %}{% endblock %}
|
||||||
|
{% include ['@override/footer.html.twig', '@novaconium/footer.html.twig'] %}
|
||||||
|
{% block footerafter %}{% endblock %}
|
||||||
|
</footer>
|
||||||
|
|
||||||
{% include ['@override/foot.html.twig', '@novaconium/foot.html.twig'] %}
|
{% include ['@override/foot.html.twig', '@novaconium/foot.html.twig'] %}
|
||||||
</body></html>
|
</body></html>
|
||||||
|
Loading…
Reference in New Issue
Block a user