/** * Set and get a specific post * * @param integer $id Post ID * @return void */ public function post($id = null) { if (!isset($this->_cache['post']) || $id !== null && $this->_cache['post']->get('id') != $id && $this->_cache['post']->get('alias') != $id) { $this->_cache['post'] = null; if (isset($this->_cache['posts'])) { foreach ($this->_cache['posts'] as $post) { if ($post->get('id') == $id || $post->get('alias') == $id) { $this->_cache['post'] = $post; break; } } } if (!$this->_cache['post']) { $this->_cache['post'] = Post::getInstance($id); } if (!$this->_cache['post']->exists()) { $this->_cache['post']->set('scope', $this->get('scope')); $this->_cache['post']->set('scope_id', $this->get('scope_id')); } } return $this->_cache['post']; }
total <?php echo $this->latest_cnt; ?> new ======================= Latest Discussions: <?php if (count($this->latest) > 0) { foreach ($this->latest as $post) { ?> ---------------------------------------- <?php $postObj = \Components\Forum\Models\Post::getInstance($post->id); echo User::getInstance($post->created_by)->get('name'); ?> | created: <?php echo Date::of($post->created)->toLocal('M j, Y g:i:s a') . "\n"; echo $postObj->content('raw') . "\n"; ?> ---------------------------------------- <?php } } else { ?> No new comments to display <?php