How to create HMVC(Hierarchical Model View Controller)?
Download HMVC Library from https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/downloads/
It contains two folder folder core & third_party. Put files from those folder to your application/config/core & application/config/third_party
now check your site if it show error "Fatal error: Call to undefined method MY_Loader::_ci_object_to_array() in" then change Line 300 in third_party/MX/Loader.php
return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
with
if (method_exists($this, '_ci_object_to_array'))
{
return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
} else {
return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_prepare_view_vars($vars), '_ci_return' => $return));
}
Now create Folder in application/config/modules/foo/views/yourview.php & application/config/modules/foo/controllers/Foo.php
create same way for another application/config/modules/bar/views/yourview.php & application/config/modules/bar/controllers/Boo.php
now access
http://localhost/yourproject/index.php/foo
http://localhost/yourproject/index.php/bar
Now if you want to access bar controller in foo view you can call as
<?php
// syntax Modules::run("module/controller/function");
echo Modules::run("bar/bar/index");
?>
Download HMVC Library from https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/downloads/
It contains two folder folder core & third_party. Put files from those folder to your application/config/core & application/config/third_party
now check your site if it show error "Fatal error: Call to undefined method MY_Loader::_ci_object_to_array() in" then change Line 300 in third_party/MX/Loader.php
return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
with
if (method_exists($this, '_ci_object_to_array'))
{
return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
} else {
return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_prepare_view_vars($vars), '_ci_return' => $return));
}
Now create Folder in application/config/modules/foo/views/yourview.php & application/config/modules/foo/controllers/Foo.php
create same way for another application/config/modules/bar/views/yourview.php & application/config/modules/bar/controllers/Boo.php
now access
http://localhost/yourproject/index.php/foo
http://localhost/yourproject/index.php/bar
Now if you want to access bar controller in foo view you can call as
<?php
// syntax Modules::run("module/controller/function");
echo Modules::run("bar/bar/index");
?>
0 comments: