public function executeView(sfWebRequest $request) { $category = CategoryPeer::retrieveByName($request->getParameter('category_name')); $this->forward404Unless($category); if ($category->getParentId() != 0) { $this->parentCategory = CategoryPeer::retrieveByPk($category->getParentId()); } else { $this->subCategorys = CategoryPeer::getAllSub($category->getId()); } $c = new Criteria(); if (isset($this->subCategorys)) { $subCategoryIds = array(); foreach ($this->subCategorys[$category->getId()] as $sub) { $subCategoryIds[] = $sub->getId(); } $subCategoryIds[] = $category->getId(); $c->add(ElementPeer::CATEGORY_ID, $subCategoryIds, Criteria::IN); } else { $c->add(ElementPeer::CATEGORY_ID, $category->getId()); } $this->pager = new sfPropelPager('Element', 10); $this->pager->setPeerMethod('doSelectJoinAll'); $this->pager->setCriteria($c); $this->pager->setPage($this->getRequestParameter('page'), 1); $this->pager->init(); $this->elements = $this->pager->getResults(); $this->category = $category; }
public function executeIndex(sfWebRequest $request) { $this->parentCategory = CategoryPeer::getAllParent(); $this->subCategory = CategoryPeer::getAllSub(); }
?> <?php if ($pager->haveToPaginate()) { ?> <?php echo __('(page %%page%%/%%nb_pages%%)', array('%%page%%' => $pager->getPage(), '%%nb_pages%%' => $pager->getLastPage()), 'sf_admin'); ?> <?php } ?> </th> </tr> </tfoot> <tbody> <?php $categorys = CategoryPeer::getAllSub(); ?> <?php foreach ($pager->getResults() as $i => $Category) { $odd = fmod(++$i, 2) ? 'odd' : 'even'; ?> <tr class="sf_admin_row <?php echo $odd; ?> "> <?php include_partial('category/list_td_stacked', array('Category' => $Category)); ?> <?php include_partial('category/list_td_actions', array('Category' => $Category, 'helper' => $helper)); ?>