diff --git a/public_html/classes/blogpost.php b/public_html/classes/blogpost.php
index 898bc05..2e83fa4 100644
--- a/public_html/classes/blogpost.php
+++ b/public_html/classes/blogpost.php
@@ -23,7 +23,8 @@ class BlogPost extends CPHPDatabaseRecordClass
'string' => array(
'Title' => "Title",
'Body' => "Body",
- 'Slug' => "Slug"
+ 'Slug' => "Slug",
+ 'Thumbnail' => "Thumbnail"
),
'numeric' => array(
'Views' => "Views",
diff --git a/public_html/modules/blog/home.php b/public_html/modules/blog/home.php
index 6550bb9..ba637bd 100644
--- a/public_html/modules/blog/home.php
+++ b/public_html/modules/blog/home.php
@@ -13,5 +13,63 @@
if(!isset($_APP)) { die("Unauthorized."); }
+$current_page = empty($router->uParameters[1]) ? 1 : (int) $router->uParameters[1];
+$current_page = ($current_page < 1) ? 1 : $current_page;
+
+$per_page = 5;
+$start = ($current_page - 1) * $per_page;
+
+$result = $database->CachedQuery("SELECT COUNT(*) FROM blog_posts WHERE `Visible` = 1");
+$total_posts = $result->data[0]["COUNT(*)"];
+$total_pages = ceil($total_posts / $per_page);
+
+$sPosts = array();
+
+try
+{
+ $result = BlogPost::CreateFromQuery("SELECT * FROM blog_posts WHERE `Visible` = 1 ORDER BY `Posted` DESC LIMIT {$start},{$per_page}");
+}
+catch (NotFoundException $e)
+{
+ $result = array();
+}
+
+foreach($result as $sBlogPost)
+{
+ $sPosts[] = array(
+ "title" => $sBlogPost->sTitle,
+ "author" => $sBlogPost->sAuthor->sUsername,
+ "relative-date" => time_ago($sBlogPost->sPostedDate, $locale),
+ "teaser" => Markdown(cut_text($sBlogPost->sBody, 1000)),
+ "thumbnail" => $sBlogPost->sThumbnail,
+ "tags" => "test1, test2, test3",
+ "url" => "/blog/{$sBlogPost->sSlug}"
+ );
+}
+
+$sPages = array();
+
+foreach(generate_pagination(1, $total_pages, $current_page, 2, 3, 3) as $page)
+{
+ if($page === null)
+ {
+ $sPages[] = array('value' => false);
+ }
+ else
+ {
+ $sPages[] = array(
+ 'value' => $page,
+ 'current' => ($page == $current_page)
+ );
+ }
+}
+
$sPageTitle = "Latest posts";
-$sPageContents = NewTemplater::Render("blog/home", $locale->strings, array());
+$sPageContents = NewTemplater::Render("blog/home", $locale->strings, array(
+ "entries" => $sPosts,
+ "pagination-first" => ($current_page == 1),
+ "pagination-last" => ($current_page == $total_pages),
+ "previous-page" => ($current_page - 1),
+ "next-page" => ($current_page + 1),
+ "pages" => $sPages
+));
diff --git a/public_html/rewrite.php b/public_html/rewrite.php
index 6a0bb3c..efe3d32 100644
--- a/public_html/rewrite.php
+++ b/public_html/rewrite.php
@@ -32,6 +32,10 @@ $router->routes = array(
"target" => "modules/blog/home.php",
"_section" => "Blog"
),
+ "^/blog/p([0-9]+)$" => array(
+ "target" => "modules/blog/home.php",
+ "_section" => "Blog"
+ ),
"^/login$" => array(
"target" => "modules/account/login.php",
"_section" => "Account"
diff --git a/public_html/templates/blog/home.tpl b/public_html/templates/blog/home.tpl
index de5c58e..20b58bc 100644
--- a/public_html/templates/blog/home.tpl
+++ b/public_html/templates/blog/home.tpl
@@ -1,38 +1,27 @@
-
-
-
-
+{%/foreach}
-
-
-
-
- 2 days ago, by
- joepie91
- Tags: germany, kvm
-
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam gravida nisi ut sapien dignissim ornare. Ut nisl eros, pharetra molestie malesuada vitae, elementum sit amet dui. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Curabitur elementum leo et erat malesuada id convallis nibh faucibus. Etiam tempor faucibus urna ut blandit. Pellentesque laoreet est vel risus lobortis vehicula. Vestibulum interdum lectus et metus hendrerit ullamcorper.
-
Suspendisse libero massa, mattis at laoreet vel, tincidunt id arcu. Curabitur ac suscipit tellus. In hac habitasse platea dictumst. Donec sed leo arcu. Maecenas tempor nunc et nisi ullamcorper nec interdum lorem porttitor. In suscipit semper justo, ut pellentesque sapien ultrices a. Nam ut viverra erat. Nulla facilisi. Mauris auctor eleifend dui id vestibulum. Ut varius, odio tempus pellentesque imperdiet, tortor sapien faucibus justo, ut iaculis velit velit at leo.
-
Read more...
-
-
-
-
-
-
- 4 days ago, by
- joepie91
- Tags: netherlands, openvz
-
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam gravida nisi ut sapien dignissim ornare. Ut nisl eros, pharetra molestie malesuada vitae, elementum sit amet dui. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Curabitur elementum leo et erat malesuada id convallis nibh faucibus. Etiam tempor faucibus urna ut blandit. Pellentesque laoreet est vel risus lobortis vehicula. Vestibulum interdum lectus et metus hendrerit ullamcorper.
-
Suspendisse libero massa, mattis at laoreet vel, tincidunt id arcu. Curabitur ac suscipit tellus. In hac habitasse platea dictumst. Donec sed leo arcu. Maecenas tempor nunc et nisi ullamcorper nec interdum lorem porttitor. In suscipit semper justo, ut pellentesque sapien ultrices a. Nam ut viverra erat. Nulla facilisi. Mauris auctor eleifend dui id vestibulum. Ut varius, odio tempus pellentesque imperdiet, tortor sapien faucibus justo, ut iaculis velit velit at leo.
-
Read more...
+