Lobezki
Новичок
При переходе на url необходимой мне категории пишет bool (false).
PHP:
public function getCategoryIdByUrl($url)
{
$data = DB::select('id')
->from($this->tableName)
->where('url', '=', $url)
->execute()
->current();
var_dump($data);
exit;
if (!isset($data['id'])) return FALSE;
return $data['id'];
}
PHP:
public function action_index()
{
$category = new Model_Category('tree');
$data['categories'] = $category->getTree();
if(isset($_POST['btnsubmit']))
{
$categoryName = Arr::get($_POST, 'categoryName', '');
$parentId = Arr::get($_POST, 'parentId', '');
$url = Arr::get($_POST, 'url', '');
$res = $category->catInsert($parentId, array('name'=>$categoryName, 'url'=>$url));
if($res)
{
Controller::redirect($uri ='admin');
}
else
{
$data['errors'] = $category->getErrors();
}
}
$this->template->content = View::factory('adminview', $data);
}
PHP:
public function action_category($url = NULL)
{
$data = array();
$category = new Model_Category('tree');
//$material = new Model_Material();
$category_id = $category->getCategoryIdByUrl($url);
if(!$category_id) $this->request->redirect('');
$data['Materials'] = $material->getMaterialsByCategory($category_id);
$this->template->content = View::factory('materialsview', $data);
}