带有外部视图文件的cakephp
我被要求作为网站展示的CMS,其中应包含使用CakePHP实现的表单 不幸的是,这两个系统都使用目录结构,它们彼此不兼容:CakePHP需要一个包含多个子文件夹“Model”、“View”、“Controller”的“app”文件夹,而webEdition提供了(php)模板文件,前端(html)文件是通过http后端生成的,必须保持功能正常(因为这是使用webEdition的首要目的) 因此,虽然我可以将模型和控制器文件放入各自的CakePHP文件夹中,但我需要将视图代码写入webEdition templates.CakePHP以将其整个“app”文件夹移动到任意位置,但这可能不是我所需要的 总而言之,情况如下:带有外部视图文件的cakephp,cakephp,Cakephp,我被要求作为网站展示的CMS,其中应包含使用CakePHP实现的表单 不幸的是,这两个系统都使用目录结构,它们彼此不兼容:CakePHP需要一个包含多个子文件夹“Model”、“View”、“Controller”的“app”文件夹,而webEdition提供了(php)模板文件,前端(html)文件是通过http后端生成的,必须保持功能正常(因为这是使用webEdition的首要目的) 因此,虽然我可以将模型和控制器文件放入各自的CakePHP文件夹中,但我需要将视图代码写入webEditio
- webEdition需要模板才能转到[webroot]/webEdition/we/templates/[file].php
- CakePHP需要查看文件才能转到[任意]/app/View/[控制器名称]/[文件].[扩展名]
- 视图代码必须放入模板中
- 对视图代码的引用必须引用已发布的文件[webroot]/[file].html
显然,这些要求是不兼容的。也许我的理解一开始就错了,但即使没有,也应该(希望)有一种替代方法来实现这一点。这些要求显然是不兼容的,但有几种方法可以解决这一问题:
- 使用AJAX或iframe生成CakePHP表单,以直接调用CakePHP应用程序
- 让webEdition完全自己处理表单,但将其写入Cake应用程序正在使用的DB表
- 有一个RESTful API,您可以从webEdition页面调用,并将数据发布到CakePHP应用程序
/**
* The settings below can be used to set additional paths to models, views and controllers.
*
* App::build(array(
* 'Model' => array('/path/to/models/', '/next/path/to/models/'),
* 'Model/Behavior' => array('/path/to/behaviors/', '/next/path/to/behaviors/'),
* 'Model/Datasource' => array('/path/to/datasources/', '/next/path/to/datasources/'),
* 'Model/Datasource/Database' => array('/path/to/databases/', '/next/path/to/database/'),
* 'Model/Datasource/Session' => array('/path/to/sessions/', '/next/path/to/sessions/'),
* 'Controller' => array('/path/to/controllers/', '/next/path/to/controllers/'),
* 'Controller/Component' => array('/path/to/components/', '/next/path/to/components/'),
* 'Controller/Component/Auth' => array('/path/to/auths/', '/next/path/to/auths/'),
* 'Controller/Component/Acl' => array('/path/to/acls/', '/next/path/to/acls/'),
* 'View' => array('/path/to/views/', '/next/path/to/views/'),
* 'View/Helper' => array('/path/to/helpers/', '/next/path/to/helpers/'),
* 'Console' => array('/path/to/consoles/', '/next/path/to/consoles/'),
* 'Console/Command' => array('/path/to/commands/', '/next/path/to/commands/'),
* 'Console/Command/Task' => array('/path/to/tasks/', '/next/path/to/tasks/'),
* 'Lib' => array('/path/to/libs/', '/next/path/to/libs/'),
* 'Locale' => array('/path/to/locales/', '/next/path/to/locales/'),
* 'Vendor' => array('/path/to/vendors/', '/next/path/to/vendors/'),
* 'Plugin' => array('/path/to/plugins/', '/next/path/to/plugins/'),
* ));
*
*/
…虽然尚未测试,但显然不适合生产系统。呃。我想这不太理想,但可行。谢谢你。我认为你可以采用RESTful方式,在Cake中设置很容易,你可以通过JS完成整个HTTP POST。所以在CMS中,你只需要一个表单模板和一些JS。我认为这并不难做到。也许~1h的w工作?