Tuto Site avec CakePHP, Jour 1 -> redirection

Par Fantoche, il y a 14 ans


Désolé, mais je dois être le seul avec ce souci de redirection.

Je suis sur la fin du premier cours, tout fonctionne bien, sauf, la redirection après avoir modifié ou créé un article, j'arrive sur une page blanche.

J'ai comparé mon code à celui de Graf (reçu avec la video 2), mais je ne trouve rien.

Une piste vers où je devrais chercher ? Merci à vous.

8 réponses

slyvaan, il y a 14 ans

Tu as quel code ?

Fantoche, il y a 14 ans

Par exemple dans ma page "PagesController.php" :

function admin_index(){
        $d'pages'] = $this->Paginate('Post',array('type'=>'page'));
        $this->set($d);
    }

    function admin_edit($id = null){
        if($this->request->is('put') || $this->request->is('post')){
            if($this->Post->save($this->request->data)){
                $this->Session->setFlash("Le contenu a bien été modifié","notif");
                $this->redirect(array('action'=>'index'));
            }

        }elseif($id){
            $this->Post->id = $id;
            $this->request->data = $this->Post->read();
        }

    }

    function admin_delete($id){
        $this->Session->setFlash('La page a bien été supprimée','notif');
        $this->Post->delete($id);
        $this->redirect($this->referer());
    }
graphiweb, il y a 14 ans

Bonsoir, quel tutoriel a tu fais ?

Fantoche, il y a 14 ans

Bonsoir, comme indiqué dans le titre de mon post "Site avec CakePHP, Jour 1"

slyvaan, il y a 14 ans
function admin_edit($id = null){
    if($this->request->is('put') || $this->request->is('post')){
        $this->Post->set($this->request->data);
        if($this->Post->save()){
            $this->Session->setFlash("Le contenu a bien été modifié","notif");
            $this->redirect(array('action'=>'index'));
        }       
    }
    if($id){
        $this->Post->id = $id;
        $this->request->data = $this->Post->read();
    }

}

Essaie comme ça pour voir.

graphiweb, il y a 14 ans

Ops j’avais pas fais attention désoler, je suis entrain de le faire je te dirais si j'ai la même erreur.

Fantoche, il y a 14 ans

Merki slyvaan cela fonctionne ;)-)