Mage_Catalog_CategoryController Class Reference

Inheritance diagram for Mage_Catalog_CategoryController:

Mage_Core_Controller_Front_Action Mage_Core_Controller_Varien_Action

List of all members.

Public Member Functions

 viewAction ()

Protected Member Functions

 _initCatagory ()


Detailed Description

Definition at line 34 of file CategoryController.php.


Member Function Documentation

_initCatagory (  )  [protected]

Initialize requested category object

Returns:
Mage_Catalog_Model_Category

Definition at line 41 of file CategoryController.php.

00042     {
00043         Mage::dispatchEvent('catalog_controller_category_init_before', array('controller_action'=>$this));
00044         $categoryId = (int) $this->getRequest()->getParam('id', false);
00045         if (!$categoryId) {
00046             return false;
00047         }
00048 
00049         $category = Mage::getModel('catalog/category')
00050             ->setStoreId(Mage::app()->getStore()->getId())
00051             ->load($categoryId);
00052 
00053         if (!Mage::helper('catalog/category')->canShow($category)) {
00054             return false;
00055         }
00056         Mage::getSingleton('catalog/session')->setLastVisitedCategoryId($category->getId());
00057         Mage::register('current_category', $category);
00058         try {
00059             Mage::dispatchEvent('catalog_controller_category_init_after', array('category'=>$category, 'controller_action'=>$this));
00060         } catch (Mage_Core_Exception $e) {
00061             Mage::logException($e);
00062             return false;
00063         }
00064         return $category;
00065     }

viewAction (  ) 

Category view action

Definition at line 70 of file CategoryController.php.

00071     {
00072 
00073         if ($category = $this->_initCatagory()) {
00074 
00075             Mage::getModel('catalog/design')->applyDesign($category, Mage_Catalog_Model_Design::APPLY_FOR_CATEGORY);
00076             Mage::getSingleton('catalog/session')->setLastViewedCategoryId($category->getId());
00077 
00078             $update = $this->getLayout()->getUpdate();
00079             $update->addHandle('default');
00080 
00081             if (!$category->hasChildren()) {
00082                 $update->addHandle('catalog_category_layered_nochildren');
00083             }
00084 
00085             $this->addActionLayoutHandles();
00086 
00087             $update->addHandle($category->getLayoutUpdateHandle());
00088             $update->addHandle('CATEGORY_'.$category->getId());
00089 
00090 
00091 
00092             if ($category->getPageLayout()) {
00093                     $this->getLayout()->helper('page/layout')
00094                         ->applyHandle($category->getPageLayout());
00095             }
00096 
00097             $this->loadLayoutUpdates();
00098 
00099             $update->addUpdate($category->getCustomLayoutUpdate());
00100 
00101             $this->generateLayoutXml()->generateLayoutBlocks();
00102 
00103             if ($category->getPageLayout()) {
00104                 $this->getLayout()->helper('page/layout')
00105                     ->applyTemplate($category->getPageLayout());
00106             }
00107 
00108             if ($root = $this->getLayout()->getBlock('root')) {
00109                 $root->addBodyClass('categorypath-'.$category->getUrlPath())
00110                     ->addBodyClass('category-'.$category->getUrlKey());
00111             }
00112 
00113             $this->_initLayoutMessages('catalog/session');
00114             $this->_initLayoutMessages('checkout/session');
00115             $this->renderLayout();
00116         }
00117         elseif (!$this->getResponse()->isRedirect()) {
00118             $this->_forward('noRoute');
00119         }
00120     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:37 2009 for Magento by  doxygen 1.5.8