From 5441a22ccfbdb3381b7d585b12d91b3bf3aaa167 Mon Sep 17 00:00:00 2001 From: dignajar Date: Fri, 8 Jan 2016 12:46:52 -0300 Subject: [PATCH] latest post plugin --- plugins/latest_posts/languages/en_US.json | 15 ++++++ plugins/latest_posts/plugin.php | 59 +++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 plugins/latest_posts/languages/en_US.json create mode 100644 plugins/latest_posts/plugin.php diff --git a/plugins/latest_posts/languages/en_US.json b/plugins/latest_posts/languages/en_US.json new file mode 100644 index 00000000..4740606c --- /dev/null +++ b/plugins/latest_posts/languages/en_US.json @@ -0,0 +1,15 @@ +{ + "plugin-data": + { + "name": "Latest posts", + "description": "Shows the latest posts published.", + "author": "Bludit", + "email": "", + "website": "https://github.com/dignajar/bludit-plugins", + "version": "1.0", + "releaseDate": "2016-01-08" + }, + + "home": "Home", + "show-home-link": "Show home link" +} \ No newline at end of file diff --git a/plugins/latest_posts/plugin.php b/plugins/latest_posts/plugin.php new file mode 100644 index 00000000..d8dc1af5 --- /dev/null +++ b/plugins/latest_posts/plugin.php @@ -0,0 +1,59 @@ +dbFields = array( + 'label'=>'Latest posts', + 'amount'=>5 + ); + } + + public function form() + { + global $Language; + + $html = '
'; + $html .= ''; + $html .= ''; + $html .= '
'; + + $html .= '
'; + $html .= ''; + $html .= ''; + $html .= '
'; + + return $html; + } + + public function siteSidebar() + { + // This function is declared in 70.posts.php + $posts = buildPostsForPage(0, $this->getDbField('amount'), true, false); + + $html = '
'; + + // Print the label if not empty. + $label = $this->getDbField('label'); + if( !empty($label) ) { + $html .= '

'.$label.'

'; + } + + $html .= '
'; + $html .= '
    '; + + foreach($posts as $Post) + { + $html .= '
  • '; + $html .= ''.$Post->title().''; + $html .= '
  • '; + } + + $html .= '
'; + $html .= '
'; + $html .= '
'; + + return $html; + } +} \ No newline at end of file