_prepareCollection(); $tag = $this->getRequest()->getParam('tag'); if ($tag) { $collection->addTagFilter(urldecode($tag)); } parent::_processCollection($collection); return $collection; } protected function _prepareLayout() { if ($this->isBlogPage() && ($breadcrumbs = $this->getCrumbs())) { parent::_prepareMetaData(self::$_helper); $tag = $this->getRequest()->getParam('tag', false); if ($tag) { $tag = urldecode($tag); $breadcrumbs->addCrumb( 'blog', array( 'label' => self::$_helper->getTitle(), 'title' => $this->__('Return to ' . self::$_helper->getTitle()), 'link' => $this->getBlogUrl(), ) ); $breadcrumbs->addCrumb( 'blog_tag', array( 'label' => $this->__('Tagged with "%s"', self::$_helper->convertSlashes($tag)), 'title' => $this->__('Tagged with "%s"', $tag), ) ); } else { $breadcrumbs->addCrumb('blog', array('label' => self::$_helper->getTitle())); } } } protected function _prepareCollection() { if (!$this->getData('cached_collection')) { $sortOrder = $this->getRequest()->getParam('order', self::DEFAULT_SORT_ORDER); $sortDirection = $this->getCurrentDirection(); $collection = Mage::getModel('blog/blog')->getCollection() ->addPresentFilter() ->addEnableFilter(AW_Blog_Model_Status::STATUS_ENABLED) ->addStoreFilter() ->joinComments() ; $collection->setOrder($collection->getConnection()->quote($sortOrder), $sortDirection); $collection->setPageSize((int)self::$_helper->postsPerPage()); $this->setData('cached_collection', $collection); } return $this->getData('cached_collection'); } public function getCurrentDirection() { $dir = $this->getRequest()->getParam('dir'); if (in_array($dir, array('asc', 'desc'))) { return $dir; } return Mage::helper('blog')->defaultPostSort(Mage::app()->getStore()->getId()); } }