Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactoring themes/views to use a centralized location instead of all…

…owing plugins to have themes.

The plugin should include all required views/assets, to override these at the application level using themes you would create:
<app_name>/views/themed/<theme_name>/<plugin_name>/<controller_name>/*.ctp

if you are not using themes you can override them at the app view level:
<app_name>/views/<plugin_name>/<controller_name>/*.ctp
  • Loading branch information...
commit 21eb001a9657b6ffe9bc80fb352969819e4b3606 1 parent 2eb85ef
@phpnut phpnut authored
View
9 cake/libs/view/theme.php
@@ -55,7 +55,14 @@ function _paths($plugin = null, $cached = true) {
if (!empty($this->theme)) {
$count = count($paths);
for ($i = 0; $i < $count; $i++) {
- $themePaths[] = $paths[$i] . 'themed'. DS . $this->theme . DS;
+ if (strpos($paths[$i], DS . 'plugins' . DS) === false
+ && 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;
+ }
}
$paths = array_merge($themePaths, $paths);
}
View
2  cake/libs/view/view.php
@@ -939,7 +939,7 @@ function _paths($plugin = null, $cached = true) {
$count = count($viewPaths);
for ($i = 0; $i < $count; $i++) {
if (!isset($corePaths[$viewPaths[$i]])) {
- $paths[] = $viewPaths[$i] . 'plugins' . DS . $plugin . DS;
+ $paths[] = $viewPaths[$i] . $plugin . DS;
}
}
$paths[] = App::pluginPath($plugin) . 'views' . DS;
View
8 cake/tests/cases/libs/view/theme.test.php
@@ -199,19 +199,19 @@ function endTest() {
* @access public
* @return void
*/
- function testPluginGetTemplate() {
+ function testPluginThemedGetTemplate() {
$this->Controller->plugin = 'test_plugin';
$this->Controller->name = 'TestPlugin';
$this->Controller->viewPath = 'tests';
$this->Controller->action = 'index';
- $this->Controller->theme = 'test_plugin_theme';
+ $this->Controller->theme = 'test_theme';
$ThemeView = new TestThemeView($this->Controller);
- $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'test_plugin' . DS . 'views' . DS . 'themed' . DS . 'test_plugin_theme' . DS .'tests' . DS .'index.ctp';
+ $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';
$result = $ThemeView->getViewFileName('index');
$this->assertEqual($result, $expected);
- $expected = TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS .'test_plugin' . DS . 'views' . DS . 'themed' . DS . 'test_plugin_theme' . DS . 'layouts' . DS .'default.ctp';
+ $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';
$result = $ThemeView->getLayoutFileName();
$this->assertEqual($result, $expected);
}
View
0  ...iews/themed/test_plugin_theme/layouts/default.ctp → ...themed/test_theme/test_plugin/layouts/default.ctp
File renamed without changes
View
0  ...in/views/themed/test_plugin_theme/tests/index.ctp → ...ews/themed/test_theme/test_plugin/tests/index.ctp
File renamed without changes
Please sign in to comment.
Something went wrong with that request. Please try again.