Configure html files with twig

This commit is contained in:
Gregorio Chiko Putra 2017-09-04 15:05:54 +07:00
parent e7b5eec29d
commit 424737117a
7 changed files with 101 additions and 96 deletions

View File

@ -7,14 +7,14 @@ class Home
{ {
public function index() public function index()
{ {
echo "This is index of home"; // Nanti di replace sama twig view ke App\Views\Data\pengumuman.html // echo "This is index of home"; // Nanti di replace sama twig view ke App\Views\Data\pengumuman.html
View::render('Data/pengumuman.html'); View::render('Data/pengumuman.html');
return true; return true;
} }
public function login() public function login()
{ {
echo "You have to login"; // Nanti di replace sama twig view ke App\Views\Access\login.html // echo "You have to login"; // Nanti di replace sama twig view ke App\Views\Access\login.html
View::render('Access/login.html'); View::render('Access/login.html');
return true; return true;
} }

View File

@ -7,14 +7,14 @@ class Posts
{ {
public function index() public function index()
{ {
echo "This is index of posts."; // Nanti di replace sama twig view ke App\Views\Data\pengumuman.html // echo "This is index of posts."; // Nanti di replace sama twig view ke App\Views\Data\pengumuman.html
View::render('Data/pengumuman.html'); View::render('Data/pengumuman.html');
return true; return true;
} }
public function entry() public function entry()
{ {
echo "You can entry new data here."; // Nanti di replace sama twig view ke App\Views\Data\entry_pengumuman.html // echo "You can entry new data here."; // Nanti di replace sama twig view ke App\Views\Data\entry_pengumuman.html
View::render('Data/entry_pengumuman.html'); View::render('Data/entry_pengumuman.html');
return true; return true;
} }
@ -22,7 +22,7 @@ class Posts
public function edit($id = null) public function edit($id = null)
{ {
if ($id) { if ($id) {
echo "You can edit exists data with id $id here"; // Nanti di replace sama twig view ke App\Views\Data\edit_pengumuman.html // echo "You can edit exists data with id $id here"; // Nanti di replace sama twig view ke App\Views\Data\edit_pengumuman.html
View::render('Data/edit_pengumuman.html'); View::render('Data/edit_pengumuman.html');
return true; return true;
} }

View File

@ -20,7 +20,7 @@
<input type="hidden" name="_method" value="post"> <input type="hidden" name="_method" value="post">
<!-- Token --> <!-- Token -->
<input type="hidden" name="_token_" value="##TOKEN##"> <input type="hidden" name="_token" value="##TOKEN##">
<br> <br>

View File

@ -1,10 +1,8 @@
<!DOCTYPE html> {% extends "base.html" %}
<html>
<head> {% block title %}Edit Pengumuman{% endblock %}
<meta charset="utf-8">
<title>Edit Pengumuman</title> {% block body %}
</head>
<body>
<form method="post"> <form method="post">
<h3>Pengumuman 1</h3> <h3>Pengumuman 1</h3>
@ -54,5 +52,4 @@
<button type="submit" name="edit">Edit</button> <button type="submit" name="edit">Edit</button>
</form> </form>
</body> {% endblock %}
</html>

View File

@ -1,10 +1,8 @@
<!DOCTYPE html> {% extends "base.html" %}
<html>
<head> {% block title %}Tambah Pengumuman{% endblock %}
<meta charset="utf-8">
<title>Tambah Pengumuman</title> {% block body %}
</head>
<body>
<form method="post"> <form method="post">
<h3>Tambah Pengumuman</h3> <h3>Tambah Pengumuman</h3>
@ -32,5 +30,4 @@
<button type="submit" name="entry">Entry</button> <button type="submit" name="entry">Entry</button>
</form> </form>
</body> {% endblock %}
</html>

View File

@ -1,22 +1,21 @@
<!DOCTYPE html> {% extends "base.html" %}
<html>
<head> {% block title %}Pengumuman{% endblock %}
<meta charset="utf-8">
<title>Pengumuman</title> {% block body %}
</head>
<body>
<h2>List Pengumuman</h2> <h2>List Pengumuman</h2>
<h3><a href="#">Pengumuman 1</a></h3> <h3>Pengumuman 1</h3>
<code><a href="#">Edit</a></code> <code><a href="./posts/edit/1">Edit</a></code>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
<h3><a href="#">Pengumuman 1</a></h3> <h3>Pengumuman 1</h3>
<code><a href="#">Edit</a></code> <code><a href="./posts/edit/2">Edit</a></code>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
<h3><a href="#">Pengumuman 1</a></h3> <h3>Pengumuman 1</h3>
<code><a href="#">Edit</a></code> <code><a href="./posts/edit/3">Edit</a></code>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
</body>
</html> <a href="./posts/entry">+ Tambah Pengumuman</a>
{% endblock %}

12
App/Views/base.html Normal file
View File

@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{% block title %}{% endblock %}</title>
</head>
<body>
<a href="/">Home</a>
{% block body %}
{% endblock %}
</body>
</html>