Refactored last commit changes are:

To override plugin views with a themed version of the view you would create:
<app_name>/views/themed/<theme_name>/plugins/<plugin_name>/<controller_name>/*.ctp

To override plugin views at the app view level you would create:
<app_name>/views/plugins/<plugin_name>/<controller_name>/*.ctp
This commit is contained in:
phpnut 2009-11-25 22:58:02 -06:00
parent 21eb001a96
commit 948f6b21e5
5 changed files with 6 additions and 5 deletions

View file

@ -59,9 +59,10 @@ class ThemeView extends View {
&& strpos($paths[$i], DS . 'libs' . DS . 'view') === false
&& strpos($paths[$i], DS . $plugin . DS) === false) {
if ($plugin) {
$themePaths[] = $paths[$i] . 'themed'. DS . $this->theme . DS . $plugin . DS;
$themePaths[] = $paths[$i] . 'themed'. DS . $this->theme . DS . 'plugins' . DS . $plugin . DS;
} else {
$themePaths[] = $paths[$i] . 'themed'. DS . $this->theme . DS;
}
$themePaths[] = $paths[$i] . 'themed'. DS . $this->theme . DS;
}
}
$paths = array_merge($themePaths, $paths);

View file

@ -939,7 +939,7 @@ class View extends Object {
$count = count($viewPaths);
for ($i = 0; $i < $count; $i++) {
if (!isset($corePaths[$viewPaths[$i]])) {
$paths[] = $viewPaths[$i] . $plugin . DS;
$paths[] = $viewPaths[$i] . 'plugins' . DS . $plugin . DS;
}
}
$paths[] = App::pluginPath($plugin) . 'views' . DS;

View file

@ -207,11 +207,11 @@ class ThemeViewTest extends CakeTestCase {
$this->Controller->theme = 'test_theme';
$ThemeView = new TestThemeView($this->Controller);
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'test_plugin' . DS . 'tests' . DS .'index.ctp';
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'plugins' . DS . 'test_plugin' . DS . 'tests' . DS .'index.ctp';
$result = $ThemeView->getViewFileName('index');
$this->assertEqual($result, $expected);
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'test_plugin' . DS . 'layouts' . DS .'default.ctp';
$expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'plugins' . DS . 'test_plugin' . DS . 'layouts' . DS .'default.ctp';
$result = $ThemeView->getLayoutFileName();
$this->assertEqual($result, $expected);
}