<?php

class StoFilterController extends Controller
{

    /** @var array General Section Params */
    public $generalData;

    public function init()
    {
        parent::init();
        /** @var $sectionData StaticData */
        $sectionData = StaticData::model()->with('i18n')->findByPk(array('section' => $this->id, 'key' => 'general'));
        $this->generalData = $sectionData->getDataAttributes() + $sectionData->i18n->getDataAttributes();
        $this->headerGalleryId = $this->generalData['gallery_id'];
    }

    public function actionIndex(){
        $data = $this->loadStaticPage($this->id, $this->action->id);
        $this->sectionGalleryId = $data['gallery_id'];

        $this->setContacts($data['contacts']);
        $this->setContacts($this->generalData['contacts']);

        $brands = StoFilter::model()->findAll(array(
            'select'=>'brand',
            'group'=>'brand',
            'distinct'=>true,
            ));


        $this->render('index', array(
            'content' => $data['content'],
            'brands' =>$brands
        ));
    }


}