/** * Shows the top topics, by views. * * @param int $num_topics = 10 * @param string $output_method = 'echo' */ function ssi_topTopicsViews($num_topics = 10, $output_method = 'echo') { return ssi_topTopics('views', $num_topics, $output_method); }
function sp_topTopics($parameters, $id, $return_parameters = false) { global $smcFunc, $txt, $scripturl, $user_info, $user_info, $modSettings, $topics; $block_parameters = array('type' => 'select', 'limit' => 'int'); if ($return_parameters) { return $block_parameters; } $type = !empty($parameters['type']) ? $parameters['type'] : 0; $limit = !empty($parameters['limit']) ? $parameters['limit'] : 5; $topics = ssi_topTopics($type ? 'views' : 'replies', $limit, 'array'); if (empty($topics)) { echo ' ', $txt['error_sp_no_topics_found']; return; } else { $topics[count($topics) - 1]['is_last'] = true; } echo ' <ul class="sp_list">'; foreach ($topics as $topic) { echo ' <li class="sp_list_top">', sp_embed_image('topic'), ' ', $topic['link'], '</li> <li class="sp_list_indent', empty($topic['is_last']) ? ' sp_list_bottom' : '', ' smalltext">', $txt['replies'], ': ', $topic['num_replies'], ' | ', $txt['views'], ': ', $topic['num_views'], '</li>'; } echo ' </ul>'; }
/** * Short description * * Long description * * @param * @return */ protected function show_topTopics() { try { $this->loadSSI(); } catch (Exception $e) { throw new \Exception($e->getMessage()); } if ('echo' == $this->output_method) { ob_start(); ssi_topTopics($this->type, $this->num_topics, $this->output_method); $this->data = ob_get_contents(); ob_end_clean(); } else { $this->data = ssi_topTopics($this->type, $this->num_topics, $this->output_method); } }
/** * Top Topics Block, shows top topics by number of view or number of posts * * @param mixed[] $parameters * 'limit' => number of posts to show * 'type' => 0 replies or 1 views * @param int $id - not used in this block * @param boolean $return_parameters if true returns the configuration options for the block */ function sp_topTopics($parameters, $id, $return_parameters = false) { global $txt, $user_info, $user_info, $topics; $block_parameters = array('type' => 'select', 'limit' => 'int'); if ($return_parameters) { return $block_parameters; } $type = !empty($parameters['type']) ? $parameters['type'] : 0; $limit = !empty($parameters['limit']) ? $parameters['limit'] : 5; // Use the ssi function to get the data $topics = ssi_topTopics($type ? 'views' : 'replies', $limit, 'array'); if (empty($topics)) { echo ' ', $txt['error_sp_no_topics_found']; return; } else { end($topics); $topics[key($topics)]['is_last'] = true; } echo ' <ul class="sp_list">'; foreach ($topics as $topic) { echo ' <li ', sp_embed_class('topic', '', 'sp_list_top'), '>', $topic['link'], '</li> <li class="sp_list_indent', empty($topic['is_last']) ? ' sp_list_bottom' : '', ' smalltext">', $txt['replies'], ': ', $topic['num_replies'], ' | ', $txt['views'], ': ', $topic['num_views'], '</li>'; } echo ' </ul>'; }
function widget($args, $instance) { extract($args, EXTR_SKIP); echo $before_widget; $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']); if (!empty($title)) { echo $before_title . $title . $after_title; } // WIDGET CODE GOES HERE $x = ssi_topTopics('replies', 5, 'return'); if (count($x) > 0) { //this means there are posts ?> <ul> <?php foreach ($x as $data) { $data = (object) $data; ?> <li> <div><?php echo $data->link; ?> </div> <div><span><?php echo $data->num_replies; ?> comments.<?php if (isset($data->board)) { ?> <strong><?php echo $data->board; ?> </strong><?php } ?> </div> </li> <?php } ?> </ul> <?php } else { ?> There are no popular forum topics at this time.<?php } echo $after_widget; }