Example #1
0
 /**
  * Action Default
  */
 public function actionDefault()
 {
     /** @var PagesEntity $page */
     $page = $this->pagesRepository->getOneWhere(['onHomepage' => 1]);
     $this->getTemplate()->page = $page;
     $this->getTemplate()->slider = $this->sliderRepository->getAll()->fetchAll();
     $this->setSeo(['title' => $page->title() > '' ? $page->title() : $page->name(), 'description' => $page->description() > '' ? $page->description() : $page->text(), 'keywords' => $page->keywords() > '' ? $page->keywords() : '']);
 }
Example #2
0
 /**
  * @param $name
  * @return Grid
  */
 protected function createComponentGrid($name)
 {
     $grid = new Grid($this, $name);
     $grid->translator->lang = 'cs';
     $fluent = $this->sliderRepository->getAll();
     $grid->model = $fluent;
     $grid->addColumnText('imgName', 'Obrázek')->setCustomRender(function ($item) {
         $img = Html::el('img')->src($item->imgName)->width('200');
         return $img;
     });
     $grid->addColumnText('imgTitle', 'Titulek')->setSortable()->setFilterText();
     $grid->getColumn('imgTitle')->headerPrototype->style['width'] = '20%';
     $grid->addColumnText('imgDescription', 'Popisek')->setSortable()->setFilterText();
     $grid->getColumn('imgDescription')->headerPrototype->style['width'] = '40%';
     $grid->addActionHref('edit', '')->setIcon('pencil');
     $grid->addActionEvent('delete', '')->setCustomRender(function ($item) {
         $i = Html::el('i', ['class' => 'fa fa-trash']);
         $el = Html::el('a', ['class' => 'btn btn-default btn-xs btn-mini ajax'])->href($this->presenter->link("delete!", $item->id))->setHtml($i);
         return $el;
     });
     $grid->setDefaultPerPage(50);
     $grid->filterRenderType = $this->filterRenderType;
     $grid->setExport();
     return $grid;
 }