Skip to content

Instantly share code, notes, and snippets.

@ngurajeka
Last active November 22, 2015 03:50
Show Gist options
  • Save ngurajeka/212a4e7d04d0043f2168 to your computer and use it in GitHub Desktop.
Save ngurajeka/212a4e7d04d0043f2168 to your computer and use it in GitHub Desktop.
<?php
include_once __DIR__.'/inc/Twig/lib/Twig/Autoloader.php';
include_once __DIR__.'/inc/db.php';
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem(__DIR__ . '/template');
$twig = new Twig_Environment($loader, array());
$data = array(
'judul' => 'Web Sederhana',
'deskripsi' => 'Belajar membuat web sederhana',
'list_blog' => []
);
$list_blog = $db->query('SELECT * FROM `blog`');
if ($list_blog) {
foreach ($list_blog as $i => $blog) {
$data['list_blog'][$i]['id'] = $blog['id'];
$data['list_blog'][$i]['title'] = $blog['title'];
$data['list_blog'][$i]['content'] = $blog['content'];
$data['list_blog'][$i]['date'] = $blog['date'];
}
}
echo $twig->render('gallery.html', $data);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment