Last active
August 29, 2015 14:07
-
-
Save n1215/640897eeacde100a6f74 to your computer and use it in GitHub Desktop.
【baserCMS】 ユーザーエージェントに応じて適用するテーマを変えるテスト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* app/Controller/AppController.php | |
*/ | |
App::uses('BcAppController', 'Controller'); | |
App::uses('BcAgent', 'Lib'); | |
class AppController extends BcAppController { | |
/** | |
* テーマをセットする | |
* | |
* @return void | |
*/ | |
public function setTheme() { | |
parent::setTheme(); | |
$themes = Configure::read('MyConfig.themes'); | |
$agent = BcAgent::findCurrent(); | |
if (empty($agent) || !array_key_exists($agent->name, $themes)) { | |
return; | |
} | |
$this->theme = $themes[$agent->name]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* app/Config/setting.php | |
*/ | |
$config['MyConfig'] = array( | |
'themes' => array( | |
'mobile' => 'm-single', | |
'smartphone' => 'skelton' | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment