';
$output .= '
';
foreach (ORM::factory('Product_Category')->list_active() as $pco) {
$a = ''.$pco->display('name').'
';
$a .= ''.$pco->description().'
';
$output .= '- ';
$output .= HTML::anchor('product/category/'.$pco->id,$a);
$output .= '
';
}
$output .= '
';
$output .= '';
$this->template->content = $output;
}
/**
* Show the available topics in a category
* @todo Only show categories according to their validity dates
* @todo Obey sort order
*/
public function action_category() {
$output = '';
$pco = ORM::factory('Product_Category',$this->request->param('id'));
if (! $pco->loaded())
HTTP::redirect('welcome/index');
if (! $pco->status AND ! Kohana::$config->load('debug')->show_inactive)
HTTP::redirect('welcome/index');
BreadCrumb::name($this->request->uri(),$pco->name);
BreadCrumb::url('product','product/categorys');
BreadCrumb::url('product/category','product/categorys');
foreach ($pco->products() as $po)
$output .= View::factory($this->viewpath().'/list_item')
->set('co',$pco)
->set('o',$po);
// If our output is blank, then there are no products
if (! $output)
$output = _('Sorry, no pages were found in this category, or your account is not authorized for this category.');
Block::add(array(
'title'=>sprintf('%s: %s',_('Category'),$pco->name),
'body'=>$output,
));
}
/**
* Show a product
*/
public function action_view() {
$id = $this->request->param('id');
$po = ORM::factory('Product',$id);
if (! $po->loaded())
HTTP::redirect('Product_Category/index');
BreadCrumb::name($this->request->uri(),$po->product_translate->find()->name);
BreadCrumb::url('product','product/categorys');
// Work out our category id for the control line
if (! empty($_GET['cid'])) {
$co = ORM::factory('Product_Category',$_GET['cid']);
// If the product category doesnt exist, or doesnt match the product
if (! $co->loaded() OR ! in_array($co->id,$po->avail_category))
HTTP::redirect('Product_Category/index');
BreadCrumb::name('product/view',$co->name);
BreadCrumb::url('product/view','product/category/'.$co->id);
}
Block::add(array(
'title'=>$po->product_translate->find()->description_short,
'body'=>View::factory($this->viewpath())
->set('record',$po),
));
}
}
?>