2013-10-29 37 views
1

我已經配置了我的xml,controller,model。 但我有問題與視圖和phtml文件。 請告訴我如何配置我的視圖和phtml文件來顯示圖像。如何配置視圖和phtml文件以在圖庫中顯示圖像?

這裏的控制器和模型的代碼

型號:

public function getImageUploadPath() { 
    return Fox::getUploadDirectoryPath() . DIRECTORY_SEPARATOR . 'gallery' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR; 
} 

public function getImageUploadUrl() { 
    return Fox::getUploadDirectoryUrl() . '/' . 'gallery' . '/' . 'images' . '/'; 
} 

public function getAllFolderImages() { 
    $dir = $this->getImageUploadPath(); 
    $files=array(); 
    $i=0; 
    if (is_dir($dir)) { 
     if ($dh = opendir($dir)) { 
      while (($file = readdir($dh)) !== false) { 
       if((filetype($dir . $file)=='jpg')||(filetype($dir . $file)=='png')||(filetype($dir . $file)=='gif')||(filetype($dir . $file)=='jpeg')){ 
       $files[$i]=$file; 
       $i++;      
       } 
      } 
      closedir($dh); 
     } 
    } 
    return $files; 
} 

控制器:

public function indexAction(){ 
    $this->loadLayout(); 
    $this->renderLayout(); 
} 
public function getImagesAction(){ 
    return Fox::getModel('gallery/images')->getAllFolderImages(); 
} 
public function getImagePathAction(){ 
    return Fox::getModel('gallery/images')->getImageUploadUrl(); 
} 

請告訴我現在該怎麼配置視圖和PHTML文件。

回答

1

在zend中,如果您有一個名爲newController的控制器和名爲indexAction()的操作,則默認視圖爲new/index.phtml。這意味着如果您要創建新的控制器,則必須在view/scripts/中創建一個名爲'new'的文件夾,並在'new'文件夾內創建一個名爲'index.phtml'的文件。每個新控制器的新文件夾和每個動作的新文件()

相關問題