public function tagSuggestAction() { $this->view->disable(); $this->setJsonResponse(); $q = $this->request->getQuery('q', 'string'); if ($q) { $tags = Tags::query()->Where('name LIKE "%' . $q . '%"')->execute(); $params = ['tags' => $tags->toArray()]; if ($this->request->isAjax()) { $this->view->getRender('partials', 'tags-suggestions', $params, function ($view) { $view->setRenderLevel(View::LEVEL_ACTION_VIEW); }); echo $this->view->getContent(); return 1; } //echo json_encode($data); } }
/** * @return int */ public function tagSuggestAction() { $this->view->disable(); $this->setJsonResponse(); $q = $this->request->getQuery('q', 'string'); if ($q) { $tags = Tags::query()->Where('name LIKE "%' . $q . '%"')->execute(); $params = ['tags' => $tags->toArray()]; if ($this->request->isAjax()) { /** * Hierarchical Rendering * @link https://docs.phalconphp.com/en/latest/reference/views.html#stand-alone-component */ echo $this->view->getRender('partials', 'tags-suggestions', $params, function ($view) { $view->setRenderLevel(View::LEVEL_ACTION_VIEW); }); //echo $this->view->getContent(); return 1; } } }