in ATK4 Can I define a different template from frontend to back end?

我怕爱的太早我们不能终老 提交于 2020-01-05 07:02:57

问题


For Example, I would like to use the jUI template for the Admin area and CRUD, and for the FrontEnd and Pages I'd like to use the Elephant theme (or my super secret custom one). If so How do I go about defining this. I create a separate API for each area? this is in my index.php in the Root. And I'd like to mod the Shared template and keep the old one as well. I think I am supposed to create a new Dir in root/atk4/templates/MyNewTemplate with the new jUI theme + css + images And create a new Dir in the root/atk4/templates/shared or is that defined in the page class of the main app?

include 'atk4/loader.php';
$api=new Frontend('sample_project','elephant');
$api->main();

http://agiletoolkit.org


回答1:


By definition, your administration and your frontend are DIFFERENT web application and they deserve to have a different API class. Also they should be located on different URLs so the entry-point would be different for them. the content of frontend/index.php would contain:

$api=new Frontend('MyFrontend','elephant');

while for the admin/index.php

$api=new Admin('MyAdmin');

By having separate applications like that you also making sure that authentication for the front-end will not allow users to access administration area.

While Admin classes are different, it's perfectly normal to:

  • Define common ancestor for both API classes. (class Admin extends MyApp and class Frontend extends MyApp)
  • Use same controller, especially if you need to do some calculation. For example if you are implementing Payroll Web App, you might want to have $this->payroll=$this->add('Controller_Payroll') in both of the APIs.
  • Models simply MUST be shared. Because you are accessing same database. All you need to do is to include frontend's "lib" folder as PHP resource into your admin.

Pages must not be shared, you don't want to mix pages up.



来源:https://stackoverflow.com/questions/7407410/in-atk4-can-i-define-a-different-template-from-frontend-to-back-end

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!