Skip to content

Instantly share code, notes, and snippets.

@converge
Created May 15, 2015 21:14
Show Gist options
  • Save converge/857c3e194f86f48e05bb to your computer and use it in GitHub Desktop.
Save converge/857c3e194f86f48e05bb to your computer and use it in GitHub Desktop.
<?
public function view($category = null ,$slug = null) {
if (! $slug) {
$this->Flash->success ( 'Invalid id for Product' );
$this->redirect ( '/products' );
}
$query = $this->Products->find()->where(
[
'slug =' => $slug,
'category_id =' => $category
])
->first();
debug($category);
debug($query);
if ($query == null) {
$this->Flash->success ( 'Product doesnt exist' );
$this->redirect ( '/products' );
}
$this->set ('product', $query);
$this->set ('_serialize', ['product']);
}
---
// routes.php
$routes->connect('/:category/:slug',
['controller' => 'Products', 'action' => 'view'],
['pass' => ['category', 'slug']]
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment