getRequest()->getParam('category') ? $this->getRequest()->getParam('category') : 'news'); $this->getRequest()->setParam('category', $category); if ($category) { $collection = Mage::getModel('clnews/category')->getCollection() ->addFieldToFilter('url_key', $category) ->addStoreFilter(Mage::app()->getStore()->getId()); //echo(count($collection));exit; if (count($collection) < 1) { //echo(Mage::helper('clnews')->getRoute());exit; $this->_redirect(Mage::helper('clnews')->getRoute()); } } if ($tag = $this->getRequest()->getParam('q')) { $collection = Mage::getModel('clnews/news')->getCollection() ->setOrder('news_time', 'asc'); if (count(Mage::app()->getStores()) > 1) { $tableName = Mage::getSingleton('core/resource')->getTableName('clnews_news_store'); $collection->getSelect()->join($tableName, 'main_table.news_id = ' . $tableName . '.news_id','store_id'); $collection->getSelect()->where($tableName . '.store_id =?', Mage::app()->getStore()->getId()); } $tag = urldecode($tag); $collection->getSelect()->where("main_table.tags LIKE '%". $tag . "%'"); if (count($collection) < 1) { $this->_redirect(Mage::helper('clnews')->getRoute()); } } $this->loadLayout(); $this->getLayout()->getBlock('head')->setTitle(Mage::app()->getHelper('clnews')->__(ucfirst($category))); $this->renderLayout(); } }