'custom date format', 'limit'=>'nmber of posts to show'); var $default_context = LP_CONTEXT_INDEX; var $description = 'Display the top n most recent posts'; var $active = true; var $hooks = array('sidebar'); var $date_format = ''; var $limit = 5; function SecondPage(&$frontend, $args, $dummy_run=false) { $this->LightPressPlugin($frontend, $args, $dummy_run); if (!$dummy_run && $frontend->context['index']) $this->active = false; } function run($hook, &$hook_data) { $frontend =& $this->_frontend; $tpl =& $frontend->tpl; $db =& $frontend->db; $date_format = (empty($this->date_format) ? $frontend->options['date_format'] : $this->date_format); $tpl->setFile('plugin_secondpage', 'plugins/second_page.xml'); $q = "select id, post_title as title, post_name as name, unix_timestamp(post_date) as tstamp, post_category " . "from " . $frontend->tables['posts'] . " p " . "where {$this->_frontend->get_posts_clause} and {$this->_frontend->only_published}" . "order by p.post_date desc limit {$this->_frontend->options['posts_per_page']}, {$this->limit}"; if (!$db->query($q)) return $this->hide(); $post = array(); foreach ($db->all() as $k => $v) { $v['permalink'] = $this->_frontend->getPermalink($v['id'], $v['name'], $v['tstamp'], $v['post_category']); $v['date'] = strftime($date_format, $v['tstamp']); $v['short_date'] = strftime($frontend->options['short_date_format'], $v['tstamp']); $posts[] = $v; } $tpl->parseBlock('PLUGIN_SECONDPAGE_POST', 'plugin_secondpage_post', $posts, 'plugin_secondpage'); $tpl->parse('PLUGIN_SECONDPAGE', 'plugin_secondpage'); } } ?>