Advertisement
talkingnews

subdomain as class in codeigniter

Feb 29th, 2012
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.93 KB | None | 0 0
  1. <?php
  2.  
  3. // Thanks to Catfish on Stackoverflow - see http://goo.gl/5N17r
  4.  
  5. // /ci_starter/application/core/MY_controller.php
  6.  
  7. if (!defined('BASEPATH'))
  8.     exit('No direct script access allowed');
  9.  
  10. class MY_Controller extends CI_Controller {
  11.  
  12.     protected $theme;
  13.     protected $debug;
  14.     protected $clean_output;  
  15.     public $subdomain = null;
  16.  
  17.     public function __construct() {
  18.         parent::__construct();
  19.    
  20.     $url = $_SERVER['HTTP_HOST']; // Get the domain. EX: www.foo.example.com
  21.     $host = explode('.', $url);
  22.     $subdomain = $host[0];
  23.     $this->subdomain = $subdomain;
  24.  
  25.         $this->layout->set_layout_dir('views/themes/' . $this->theme . '/layouts/');
  26.         $layout_file = (!$this->mobiledetection->isMobile()) ? 'layout' : 'mobile_layout' ;
  27.         $this->layout->set_layout($layout_file);
  28.         if(!$this->clean_output){
  29.             $this->layout->disable_clean_output();
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement