cakephp与外部View文件

时间:2014-03-18 19:29:54

标签: cakephp

我需要使用webEdition作为网络存在的CMS,其中应包含使用CakePHP实现的表单。

不幸的是,两个系统都采用了彼此不兼容的目录结构:CakePHP需要一个带有多个子文件夹的“app”文件夹,“Model”,“View”,“Controller”,而webEdition提供(php)模板文件,前端(html)文件是通过必须保持功能的http后端生成的(因为它首先使用webEdition)。

因此,虽然我可以将模型和控制器文件放入各自的CakePHP文件夹中,但我需要将视图代码写入webEdition模板。 CakePHP offers configuration files将整个“应用程序”文件夹移动到任意位置,但这可能不是我要求的。

总而言之,情况如下:

  • webEdition需要模板转到[webroot] / webedition / we / templates / [file] .php
  • CakePHP需要View文件转到[任意] / app / View / [控制器名称] / [文件]。[扩展名]
  • 视图代码必须进入模板
  • 对View代码的引用必须引用已发布的文件[webroot] / [file] .html

显然这些要求是不相容的。 Mayhap开始时我的理解是错误的,但即使不是,也应该(希望)存在另一种实现这一目标的方法。

2 个答案:

答案 0 :(得分:0)

这些要求显然是不相容的,但有几种方法可以解决这个问题:

  • 使用AJAX或iframe制作CakePHP表单直接调用CakePHP应用程序
  • 让webEdition完全自己处理表单,但写入Cake应用程序正在使用的数据库表
  • 从webEdition页面获得可以调用的RESTful API,并将数据发布到CakePHP应用程序。

答案 1 :(得分:0)

似乎通过app / Config / bootstrap.php文件中的这个设置,webroot文件夹可能被指定为View文件夹 - 这可能更像是一个hack,但应该允许将cakePHP视图代码直接写入webEdition模板,从那里传递到已发布的文件。

/**
 * 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/'),
 * ));
 *
 */

......尚未经过测试,显然不适合生产系统。

相关问题