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

[eluser]elfkid[/eluser]
dear all
make very kinds of views ?


thanks
#2

[eluser]Thorpe Obazee[/eluser]
what do you mean? templates?
#3

[eluser]elfkid[/eluser]
[quote author="Chamyto" date="1228135572"]what do you mean? templates?[/quote]

yes
#4

[eluser]Rey Philip Regis[/eluser]
Template? Try using Template Library for codeigniter

http://www.williamsconcepts.com/ci/codei...plate/?v14
#5

[eluser]obiron2[/eluser]
I think he means

How do I apply different a different style sheet for each subdomain.
#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 ^_^.




Theme © iAndrew 2016 - Forum software by © MyBB