Bonjour a vous :p
Voila j ai un petit souci avec l'affichage des produits sur cakephp voici mon code:
ProductsController.php
<?php
class ProductsController extends AppController{
function index(){
$d'products'] = $this->Paginate('Product');
$this->set($d);
}
function view($id = null,$slug = null) {
if(!$id)
throw new NotFoundException('Aucune page ne correspond à cet ID');
$prods = $this->Product->find('first',array(
'conditions' => array('id' => $id,'online'=> 1)
));
if(empty($page))
throw new NotFoundException('Aucune page ne correspond à cet ID');
if($slug != $prods'Product']'slug'])
$this->redirect($prods'Product']'content'],301);
$d'prods'] = current($prods);
$this->set($d);
}
function delete($id) {
$this->Product->delete($id);
$this->Session->setFlash("Le produit a bien été supprimé du panier","notif");
$this->redirect('/');
}
function admin_edit($id = null){
if($this->request->is('put') || $this->request->is('post')){
if($this->Product->save($this->request->data)){
$this->Session->setFlash("Le contenu a bien été modifié","notif");
$this->redirect(array('action'=>'index'));
}
}elseif($id){
$this->Product->id = $id;
$this->request->data = $this->Product->read();
}
$d'products'] = $this->Product->find('list');
$this->set($d);
}
function admin_index(){
$d'products'] = $this->Paginate('Product');
$this->set($d);
}
function admin_delete($id) {
$this->Product->delete($id);
$this->Session->setFlash("Le produit a bien été supprimé du panier","notif");
$this->redirect($this->referer());
}
}
index.ctp
<?php echo $this->Html->css('styles'); ?>
<?php echo $this->Html->script('js/app.js'); ?>
<?php $this->set('title_for_layout',isset($title)?$title:'Produits'); ?>
<div id="wrap">
<div class="home">
<div class="home">
<div class="row">
<div class="wrap">
<?php foreach ($products as $k => $v): $v = current($v); ?>
<div class="box">
<div class="product full">
<a href="#"><?php echo $this->Html->image("/img/img/".$v'id'].".jpg"); ?></a>
<div class="description">
<?= $v'name']; ?>
<br />
<a href="<?= $this->Html->url(array('controller'=>'products','action'=>'view',$v'slug']));?>">Voir description</a>
<br />
<?= number_format($v'price_ht'],2,',',' '); ?> €
<br />
<?= $v'quantity']; ?> en stock.
</div>
<br />
<?php echo $this->Html->link('Ajouter au panier',array('controller'=>'paniers','action'=>'add_panier',$v'id'])); ?>
</div>
</div>
<?php endforeach ?>
</div>
</div>
</div>
</div>
</div>
<?php echo $this->Paginator->numbers(); ?>
view.ctp
<?php echo $this->Html->css('styles'); ?>
<?php echo $this->Html->script('js/app.js'); ?>
<?php $this->set('title_for_layout',isset($title)?$title:'Produits'); ?>
<div id="wrap">
<div class="home">
<div class="home">
<div class="row">
<div class="wrap">
<div class="box">
<div class="product full">
<a href="<?php echo $prods'Product']'id']; ?>">
<?php echo $this->Html->image("/img/img/".$prods'id'].".jpg"); ?>
</a>
<div class="description">
<?php echo $prods'Product']'name']; ?>
<br />
<?php echo $prods'Product']'content']; ?>
<br />
<?= number_format($prods'Product']'price_ht'],2,',',' '); ?> €
</div>
<br />
<?php echo $this->Html->link('Ajouter aux panier',array('controller'=>'paniers','action'=>'add_panier',$prods'Product']'id'])); ?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
donc voici mon principal problème quand je suis sur la page de tous les produits touts s affiche et quand je cliques sur description de produit j'ai cette erreur là: [Aucune page ne correspond à cet ID].
merci d'avance pour l aide que vous m'apporterez. :p
pour voir le probleme en live Site