2014-05-15 27 views
0

我有一個問題。我在我的項目中使用了zfcuser,現在我想創建配置文件頁面。 I'have在UserController中創建的showAction(),但是當我把網址的瀏覽器,我將得到404ZfcUser和自定義showAction()

public function showAction() 
{ 
    $id = (int) $this->params()->fromRoute('id', 0); 
    if (!$id) { 
     return $this->redirect()->toRoute('zfcuser', array(
      'action' => 'register' 
     )); 
    } 
    try { 
    $user = $this->zfcUserAuthentication()->getIdentity()->getUser($id); 
    } 

    catch (\Exception $ex) { 

     return $this->redirect()->toRoute('zfcuser', array(
      'action' => 'register' 
     )); 
    } 

    return new ViewModel(array(
     'user' => $user)); 
} 

我還創建自定義函數來獲取用戶信息都在一行。 它看起來像這樣:

public function getUser($id){ 
    $rowset = $this->tableGateway->select(array('user_id' => $id)); 
    $row = $rowset->current(); 
    return $row; 
} 

它是在實體/ user.php的

這是我在ZFC的showAction()UserController.php

我認爲它錯module.config,但反正它不工作。我將我的module.config更改爲:

'show' => array(
         'type' => 'Literal', 
         'options' => array(
          'route' => '/show[/][:id]', 
          'defaults' => array(
           'controller' => 'zfcuser', 
           'action'  => 'show', 
          ), 
         ), 
        ), 

我的問題是,我甚至無法訪問url來顯示此控制器操作。 哪裏可以解決問題。我想製作簡單的用戶個人資料頁面。

+1

是顯示ZFC用戶的childroute? – cptnk

回答

3

問題是在我看來你的路線'文字'。文字路線不能有參數。

你必須使用Segment代替

但它不是我想的唯一問題。 ZfcUser自帶包裝,個人資料頁已經存在:

看看這個完整的SlideShare上:

+0

+1文字路線就是這樣,*文字*!所以OP的路線將匹配'www.foo.com/show [/] [:id]' – AlexP

+0

+1感謝您的介紹:) – Franky238

+0

歡迎:) – Hooli