CakePHP - How do i set the page title to an item name?

后端 未结 10 891
囚心锁ツ
囚心锁ツ 2021-01-03 02:13

OK, so I\'m trying to teach myself the CakePHP framework, and I\'m trying to knock up a simple demo app for myself.

I have the controllers, views and models all set

10条回答
  •  时光取名叫无心
    2021-01-03 02:33

    In response to your own answer about oo paradigm. Its like this :

    function view($id) {
        $this->Guitar->id = $id;
        $this->Guitar->read();
        $this->pageTitle = $this->Guitar->data['Guitar']['name'];
        $this->set('data', $this->Guitar->data);
    }
    

    By the way, you should check if id is set and valid etc, since this is url user input.

提交回复
热议问题