Application Sub-Routing
Let's say we have an app called awesomeness.
Right now I have site.com/awesomeness/{action} which works 100%.
Now awesomeness has an admin section as well, so I'm currently using site.com/awesomenessadmin/{action} which I'm not very happy about.
What sort of action would I need to take to use subrouting, ie make /admin/ point to a controller and not a method. I tried making a controller called AdminController, and inheriting from my AwesomenessController. It didn't seem to work, and the other issue is the admin stuff needs to inherit from DashboardController from what I understand, and php doesn't support multiple inheritance if I recall.
Obviously I need support for many subroutes, such as /admin/event/add etc
I was thinking perhaps I need to write two apps, one of the actual user interaction, and one for the admin backend.
Any advice would be appreciated
Comments
AdminController should work. It may be that you have to delete /cache/*.ini when you add it though.
You don't need to inherit from DashboardController, but you'll need to add the methods to add side panels and whatnot. I can help you work through it in this thread, but let's get your admin controller working first. Make sure:
Thanks so much Todd, that will be highly appreciated. I've done what you've mentioned. I've also made a Github repo for this to help anyone else experiencing difficulties, and to increase visibility (Maybe this can be integrated into the docs in future?)
Here is the repo for anyone interested
Currently in class.admincontroller.php:22, notice that calling the parent controller essentially removes the required admin Styles etc. This is why I wasn't inheriting from my base Awesomeness controller in the first place;but obviously it's required for the routing. Any ideas as to how can this be fixed eloquently ?
You need to do the stuff that the dashboard controller does to go into admin mode. Add the following to your
AdminController
.In methods within your controller make sure you cann
$this->AddSideMenu()
before calling render.I actually had added that already, see this
But my issue with calling the parent init still stands :P
Call parent::Initialize() first or not at all. Should be fine if you just add the code from
Gdn_Controller->Initialize()
.