Codeigniter modular extensions HMVC won't load view - php

I am using the modular extensions HMVC add on for codeigniter.
my structure looks as follows:
modules/
-manager/
--controllers/
---manager.php
--views/
---index.php
the manager.php controller:
class Manager extends MX_Controller {
function __construct(){
parent::__construct();
}
function index(){
$data['newsletter'] = Newsletter::all();
$this->load->view('index',$data);
}
}
Routing and printing from inside the controller itself works fine, but I can't seem to load a view, get a codeigniter error saying the view file can't be found
/modules/manager/config/routes.php:
<?php
$route['module_name'] = 'manager';
It seems the views are still being called from CI's main view folder, not sure why they are not calling from the modules folder because the controller is extending the MX class

Try this:
$this->load->view('manager/index',$data);
Structure for folders:
apllication
modules
manager
config
routes.php
controllers
manager.php
views
index.php

Related

InvalidArgumentException - No hint path defined

I am trying to add controller view in my existing project that consider model view controller structure in php with laravel.
class CashFlowdataController extends Controller {
public function index() {
return view('CashFlowdata::create');
}
}
When I implement this, it shows me error for,
InvalidArgumentException
No hint path defined for [CashFlowdata].
I have added file in route.php and web.php as added other controller data. Only for this one it shows message like this.
you code is wrong you should to something like this
class CashFlowdataController extends Controller {
public function index() {
return view('CashFlowdata.create');
}
}
here CashFlowdata.create
its means in laravel
folder structure should be
view>CashFlowdata>create.blade.php
laravel view() function is a helper to load view file
ref link https://laravel.com/docs/8.x/helpers#method-view
I had the same issue in nwidart/laravel-modules due to module.json file was miss place.
I move the file to the root of module now working fine.

Codeigniter loading model from different subfolder

I'm facing one weird problem with my Codeigniter project.
I have two model files in the following paths:
models/public/Dish_model.php
models/admin/Dish_model.php
For front-end and back-end models respectively.
In the controller which is in the following path:
controllers/admin/Dish.php
I'm trying to load the admin area model file using:
$this->load->model('admin/dish_model');
But it is loading the public model file.
Even if I comment this line out the public model file still gets loaded.
This all happened suddenly it was working fine before and I haven't changed any of the mentioned files recently.
Any help?
In case anyone else encounter the same issue.
In my case and after carefully following the execution path of the controller I found that the other model was being loaded by a library in the autoload list.
Removing that library from the autoload array fixed the problem.
to call/load a model from its subdirectory or subfolder.
models/public/Dish_model.php
let's say in Dish_model
class Dish_model extends CI_Model{
public function __construct(){
parent::__construct();
}
public function the_method(){
return 'return value';
}
}
models it's a native ci model directory and public it's a subdirectory. so to load the Dish_model do this on controller
$this->load->model('public/Dish_model','DModel');
the DModel it is like an alias.
so to call the model from the controller is
echo $this->DModel->the_method();
and it will return return value
hope its help.

cakephp controller not working; view page not found

i installed fresh cakephp. its app controller working fine. but when i write my controller and its view but this result in page not found. My code is given below
class PostsController extends Controller {
public $helpers = array('Html', 'Form');
public function index() {
$this->set('posts', $this->Post->find('all'));
}
}
and create folder named Posts in view folder and over there create index.ctp file as well. but its result in page not found. Please help what may be mistake by me or is there any need to configuration. Thanks
Your controller should be named PostsController.php (ie plural)
Just spotted it, you need to extend AppController in CakePHP 2.x, not Controller: ie:
class PostsController extends AppController {
there might problem apache rewrite module. if you are using WAMP, just put on your rewrite module.

Class Not Found when extends a Class of Subdirectory Controller in ZendFramework

I've the next structure
-application
--controllers
---Sub
----DemoController.php
---IndexController.php
-models
-views
-Boostrap.php
Well, in my Sub/DemoController.php I've the next:
<?php
class Sub_DemoController extends Zend_Controller_Action
{
public function indexAction()
{
echo 'hello demo';
}
}
And my IndexController.php like this:
<?php
class IndexController extends Sub_DemoController
{
}
When I run my web throw the next error: Class 'Sub_DemoController' not found ...
I try with initialize class with Application_Sub_DemoController, but return the same result.
I don't want use modules, I know how uses modules in Zend Framewoork but I don't looking for it.
Any ideas?
You need to add resourceType to your resource autoloader add this to you bootstrap file:
$this->getResourceLoader()
->addResourceType('sub', 'controllers/Sub', 'Sub');
More: http://framework.zend.com/manual/1.12/en/zend.loader.autoloader-resource.html
Please have a look at Zend framework (1.7.5): how to change controller directory
I think you didn't set the controller directory properly or your autoloader does not work.

CodeIgniter template library problems

I am trying to use a template library with my current codeigniter project. However I am getting the following error message,
Unable to load the requested file: main.php
My file system looks like this,
/application
/themes
/views
/layouts
admin.php
In MY_Controller.php I have the following,
<?php
class Dashboard extends MY_Controller {
public function __construct()
{
parent::__construct();
}
}
?>
In my controller I have the following
<?php
class Dashboard extends MY_Controller {
public function __construct()
{
parent::__construct();
//$this->template->set_layout('admin');
}
public function index()
{
$this->template
->set_layout('admin') // application/views/layouts/two_col.php
->build('welcome_message'); // views/welcome_message
}
}
It depends what template system your using, from the sounds of it you're using Phil Sturgeon's template library.
If so open up config/template.php
and find this line:
$config['layout'] = 'main';
And edit it as applicable.
Which template system are you using? I guess it needs a file named main.php which will load the view. Or the file does not exist and you will have to add it or the path to the file is not correct

Categories