0
我對CI有點熟悉,現在我正在嘗試構建一個使用它的Web門戶。我試圖讓它足夠靈活來接受小部件/模塊。就像組件如何joomla。爲此,(我認爲)我應該創建模塊,但是可悲的部分CI默認情況下不接受任何模塊。但通過HMVC或模塊化CI,即使這可能是可能的,但由於我以前沒有使用過它們,所以從長遠來看,我不知道哪種方法適合我的情況。在Codeignitor中實現模塊的最佳技術
基本上,我想通過一個通用控制器與其他模塊及其控制器進行通信。有點像前端控制器。
例如把我的默認控制器網站和我所期待的功能會受到一定是這樣的...
class Site extends CI_Controller {
public function index() {
$appName = $this -> uri -> segment(1); // Take this as app name
$appControllerName = $this -> uri -> segment(2); // Take this as app controller name
$this -> load -> module($appName); //Loading our app Module
$this -> $appName -> load -> controller($appControllerName);
$this -> $appName -> $appControllerName -> render();
// Take Render() as one of the common method that all the modules controller should have and is reponsible for rendering the HTML
}
}
上面的代碼正是我試圖讓。有可能有更好的方法來做到這一點。無論哪種方式,我很期待您的答覆.....
我很困惑..... – joomlearner
我更新了我的答案,以更好地格式化代碼 – Philip
所以你建議,我應該使用.. HMVC模塊... – joomlearner