How to load models in dashboard pages from package
Permalink
Hello,
I can't figure out how to load a model in my custom package from a dashboard controller (or in any other part of my package).
The folder structure of my package is:
The namespace of my package is
Here is the code of my model (saved as models/my_test_model.php):
And here it the code snipped of my dashboard controller (my_navigation_settings.php):
The error that is thrown is "Class 'Concrete\Package\MyNavigationPackage\Models\MyTestModel' not found"
I already tried to change the namespaces but without luck.
Please can you explain what i'm doing wrong?
I can't figure out how to load a model in my custom package from a dashboard controller (or in any other part of my package).
The folder structure of my package is:
packages └── my_navigation_package ├── blocks │ └── my_navigation │ ├── add.php │ ├── bootstrap.php │ ├── controller.php │ ├── db.xml │ ├── edit.php │ ├── icon.png │ └── view.php ├── controller.php ├── controllers │ └── single_page │ └── dashboard
Viewing 15 lines of 26 lines. View entire code block.
The namespace of my package is
Concrete\Package\MyNavigationPackage
Here is the code of my model (saved as models/my_test_model.php):
<?php /** * Test Model */ namespace Concrete\Package\MyNavigationPackage\Models; use Concrete\Core\Legacy\Model; use Loader; class MyTestModel extends Model { // here comes the voodoo }
And here it the code snipped of my dashboard controller (my_navigation_settings.php):
<?php /** * Controller for the dashboard page */ namespace Concrete\Package\MyNavigationPackage\Controller\SinglePage\Dashboard\My; use \Concrete\Core\Page\Controller\DashboardPageController; use \Concrete\Package\MyNavigationPackage\Models\MyTestModel; class MyNavigationSettings extends DashboardPageController { function view() { // create instance of the test model $m = new MyTestModel(); } }
The error that is thrown is "Class 'Concrete\Package\MyNavigationPackage\Models\MyTestModel' not found"
I already tried to change the namespaces but without luck.
Please can you explain what i'm doing wrong?
I will give you an example that I posted in my own form question.
Custom class
path: packages/test/blocks/test/models/file.php
Block Controller
path: packages/test/blocks/test/models/file.php
Link to post:http://www.concrete5.org/community/forums/customizing_c5/package-lo...
Hope this helps