C
C
Chvalov2014-10-09 11:06:08
CMS
Chvalov, 2014-10-09 11:06:08

Two different controllers for one site on a fat-free framework, how to do it right?

I am making a website following the example: valex.net.ru/fatfree-mvc.html
There is a controller in the controllers folder under the name Controller.php
Which loads the admin template

function afterroute() {
    echo Template::instance()->render('admin_layout.html');
    }
But when I finished the admin and went to the client part, I noticed that I was loading a piece of the template with "admin_layout.html", how can I make it load this template for the admin, and "client_layout.html" for the client part?
Here is a piece of my router file
[routes]
###АДМИНКА###
# Загружает главную страницу админки
GET /admin=AdminController->admin
..............................
# Удаление пользователя
GET /admin/user/delete/@id=AdminController->admin_user_delete

###ГЛАВНАЯ (САЙТ)###
# Загружает главную страницу сайта
GET /=UserController->index

Or remove this controller and write different templates in the controllers ClientController.php and AdminController.php ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
2
2vtlk, 2014-10-20
@2vtlk

I do not like to write in text (ini) configs. I like to write everything in php code
In index.php we add a route:
In order to make a different layout, you can go in several ways:
1. Inherit the admin and client controllers from different base controllers
2. A crutch. You can override the afterroute method in each controller (where and call a different layout).

C
Chvalov, 2014-10-09
@Chvalov

I took and transferred everything from Controller.php to AdminController.php and ClientController.php corrected what I needed in each controller and deleted the old one, somehow everything is not beautiful, but it works.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question