Hi All,
This is my first learning project with trongate and I am stuck on custom routings as I am getting error while accessing the page via,
[URL]: http://localhost:8080/anca/team
[ERROR] "ERROR: View file does not exist at: C:\xampp\htdocs\anca/modules/team/views/members.php"
but I can able to access the same page from
[URL]: http://localhost:8080/anca/anca_teams/members
below are my codes
Custome Routing:[custom_routing.php]
anca module Controller:
Template Controller Code:
Template View File:
Getting error on custom routes while accessing particular method
4 years ago
4 years ago
#1
4 years ago
#2
Hello Jogesh,
Your codes need to be between code and /code tags within [ ]
From what your are showing.
I assume the following.
You are trying to call the members.php view file from a custom route.
Could you post the code for custom_routing in the config folder?
Also your module name that you are linking the route to.
I assume it is anca/modules/team/views/members.
My guess is that you are saying anca/team, when you should say anca/anca_teams
Glad to help,
Dan
Your codes need to be between code and /code tags within [ ]
From what your are showing.
I assume the following.
You are trying to call the members.php view file from a custom route.
Could you post the code for custom_routing in the config folder?
Also your module name that you are linking the route to.
I assume it is anca/modules/team/views/members.
My guess is that you are saying anca/team, when you should say anca/anca_teams
Glad to help,
Dan
4 years ago
#3
Quick guess without seeing the code may be that your controller doesn't contain a helper 'view_module' in the data object it passes to your view file (or template)?
I am guessing controller is Anca_teams.php
Does it have something like the following in the members function?
The view_module is a helper to the framework as trongate tries to figure out the location of the view file based on the loaded module according to the url, if you're overriding this with a custom route, passing it to the view/template method like this resolves that problem. It's best practice to always include this (even though it works without it in normal circumstances)
If you are already doing that....then may need to see more code to get an idea!
I am guessing controller is Anca_teams.php
Does it have something like the following in the members function?
The view_module is a helper to the framework as trongate tries to figure out the location of the view file based on the loaded module according to the url, if you're overriding this with a custom route, passing it to the view/template method like this resolves that problem. It's best practice to always include this (even though it works without it in normal circumstances)
If you are already doing that....then may need to see more code to get an idea!
4 years ago
#4
Tref you are 100% right and your post above should fix the issue
you MUST help the framework with a 'view_module' definition when using a custom route.
you MUST help the framework with a 'view_module' definition when using a custom route.
4 years ago
#5
Thnakyou djnordeen,DaFa and trefwoordpunk for your reply :)
I am sorry I didn't check the description text! for code block.
I Have updated my question body with app code.
I am sorry I didn't check the description text! for code block.
I Have updated my question body with app code.
4 years ago
#6
As Tref has already pointed out change your controller code to
And it should work, note the:
Also, you have a simple error in the custom_routing.php file, remove the ending comma in the $routes[] array
here's it working live on my server
direct path https://ums.myds.me/z69/anca_teams/members
custom route https://ums.myds.me/z69/about
The controller Anca_teams.php whipped up using the VSCode extension
Note the wonderful use of DC's new 'bootstrappy' admin panel template:)
ps. Dan you can use HTML entities for [ ] (good ref is https://dev.w3.org/html5/html-author/charref)
[code]
put code in here
[/code]
And it should work, note the:
Also, you have a simple error in the custom_routing.php file, remove the ending comma in the $routes[] array
here's it working live on my server
direct path https://ums.myds.me/z69/anca_teams/members
custom route https://ums.myds.me/z69/about
The controller Anca_teams.php whipped up using the VSCode extension
Note the wonderful use of DC's new 'bootstrappy' admin panel template:)
ps. Dan you can use HTML entities for [ ] (good ref is https://dev.w3.org/html5/html-author/charref)
[code]
put code in here
[/code]
4 years ago
#7
Thank you all, Issue resolved..... :)
I am sorry guys, my eyes couldn't find that little comma and view_module.
I am sorry guys, my eyes couldn't find that little comma and view_module.