Welcome Guest, Not a member yet? Register   Sign In
how to according domain to change web layout
#6

[eluser]Phil Sturgeon[/eluser]
You will need to put some code in a hook or a extended controller that checks $_SERVER['SERVER_NAME'].

The way my CMS does this is possibly not the nicest or easiest way, but it works, so meh!

1.) Take a look at my Layout Lib. Save it to your libraries folder and auto load it.

2.) Now set up your folder structure.

Quote:/
|-- assets/
|-- -- themes/
|-- -- -- something.com/
|-- -- -- example.com/
|-- application/
|-- system/
|-- index.php

3.) Make a controller extention

application/libraries/MY_Controller.php
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

// Code here is run before ALL controllers
class MY_Controller extends Controller {
  function MY_Controller() {
    parent::Controller();
  }
}

// Code here is run before frontend controllers
class Public_Controller extends MY_Controller {
  function Public_Controller() {
    parent::MY_Controller();

    // Set the theme view folder
    $this->data->theme_view_folder = '../assets/themes/'.$_SERVER['SERVER_NAME'].'/views/';
    $this->layout->layout_file = $this->data->theme_view_folder.'layout.php';
  }

}
?>

4.) Make controllers children of this extended class. All frontend (user facing) controllers should use:

Code:
class Blog extends Public_controller {

5.) Add the right template tags, my layout template has $page_title, $page_output, etc.

6.) To use the layout library in your controllers:

Code:
$this->layout->title('Some title'); // optional, will generate its own title
$this->layout->create('viewname', $this->data);

Instead of using $data = in your controllers, add items to $this->data.

7.) To include other files in your view folder, use the following code:

Code:
<?=$this->load->view($theme_view_folder.'viewname'); ?>


Like I said, not exactly elegant, that will be worked on later ^_^.


Messages In This Thread
how to according domain to change web layout - by El Forum - 11-30-2008, 07:53 PM
how to according domain to change web layout - by El Forum - 12-01-2008, 12:46 AM
how to according domain to change web layout - by El Forum - 12-01-2008, 07:14 AM
how to according domain to change web layout - by El Forum - 12-01-2008, 07:44 AM
how to according domain to change web layout - by El Forum - 12-01-2008, 08:06 AM
how to according domain to change web layout - by El Forum - 12-01-2008, 10:38 AM



Theme © iAndrew 2016 - Forum software by © MyBB