'Run the plugin only for this file', 'post_separator'=>'character(s) to use when joining post titles' ); var $limit_to = 'list_archives.php'; var $post_separator = '‖'; var $default_context = LP_CONTEXT_INDEX; var $description = 'Display archive months and their posts titles'; var $active = true; var $hooks = array('pre_render'); var $_extra_months = 3; function ArchivesListExtended(&$frontend, $args, $dummy_run=false) { $this->LightPressPlugin($frontend, $args, $dummy_run); if (!$dummy_run && !empty($this->limit_to) && basename($_SERVER['PHP_SELF']) != $this->limit_to) $this->active = false; } function &run($hook, &$hook_data) { $f =& $this->_frontend; $tpl =& $f->tpl; $db =& $f->db; $sep = $this->post_separator; $tpl->setFile('plugin_archiveslistextended', 'plugins/archives_list_extended.xml'); $archives = $this->_frontend->getArchives(); $q = "select id, post_name, post_title, UNIX_TIMESTAMP(post_date) as tstamp, " . "concat(year(post_date), lpad(month(post_date), 2, '0')) as archive " . "from " . $f->tables['posts'] . " " . "where post_status='publish' and post_date_gmt <= '" . $f->where_date . "' " . "order by post_date desc"; $db->query($q); $opt_url = $f->options['url']; $archive = null; foreach ($db->all() as $post) { if ($archive != $post['archive']) { if (!is_null($archive)) $archives[$archive]['posts'] = '
  • ' . implode("
  • $sep
  • ", $posts) . '
  • '; $posts = array(); $archive = $post['archive']; } $posts[] = sprintf('%s', $opt_url, $f->getPermalink($post['id'], $post['post_name'], $post['tstamp']), htmlspecialchars($post['post_title'], ENT_QUOTES)); } $archives[$archive]['posts'] = '
  • ' . implode("
  • $sep
  • ", $posts) . '
  • '; // require_once 'Var_Dump.php'; // Var_Dump::display($archives); $tpl->parseBlock( 'PLUGIN_ARCHIVESLISTEXTENDED_ARCHIVE', 'plugin_archiveslistextended_archive', $archives, 'plugin_archiveslistextended'); $tpl->parse('PLUGIN_ARCHIVESLISTEXTENDED', 'plugin_archiveslistextended'); } } ?>