I am trying to get variable from URL to pass to the Controller
The URL looks like this http://example.org/MyCategory
or http://example.org/MyCategory-1
My DB contains table for all categories that includes category_slug
column
The route is GET /@category_slug = MainController->CategorySlug
My main controller has method that supposed to handle this, which should invoke method getBySlug()
from the Categories model
Main Controller
function CategorySlug($category_slug){
$categories = new Categories($this->db);
$cat = $categories->getBySlug($category_slug);
$this->f3->set('categories',$cat);
echo \Template::instance()->render('index.html');
}
Categories Model
public function getBySlug($category_slug)
{
$this->load(array('category_slug=?', $category_slug));
return $this->query;
}
As you see from the code above, I am passing variable $category_slug
, but have an error