Is it possible to theme a plugin's view? I have a mobile theme for mobile devices and would like to use different view files for a plugins app/views as well. I have tried app/views/themed/THEME/plugin/... and /app/plugins/PLUGIN/views/themed/THEME/...none seem to work. Thanks in advance.
Copy content of your theme to: app/views/themed/THEMENAME/plugins/PLUGINNAME/ Create a ThemePluginsView class on app/libs/view/theme_plugins.php
// app/libs/view/theme_plugins.php
if (!class_exists('ThemeView'))
    App::import('Core', 'view/theme');
class ThemePluginsView extends ThemeView {
    function __construct(&$controller, $register = true) {
        parent::__construct($controller, $register);
    }
    function _paths($plugin = null, $cached = true) {
        $paths = parent::_paths($plugin, $cached);
        if (!is_string($plugin) || empty($plugin) || empty($this->theme))
            return $paths;
        // add app/plugins/PLUGIN/views/themed/THEME path 
        $dirPath = APP . 'plugins' . DS . $plugin . DS . 'views' . DS . 'themed' . DS . $this->theme . DS;
        if (is_dir($dirPath))
            $paths = array_merge(array($dirPath), $paths);
        return $paths;
    }
}
Then call it on your app_controller on beforeFilter() or usual controller on beforeFilter() like:
function beforeFilter() {
  if (!class_exists('ThemePluginsView'))
    App::import('Core', 'view/theme_plugins');
  $this->view = 'ThemePlugins';
  $this->theme = 'THEME_NAME';
}
Hope it helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With