0

I create a custom theme with name "uni" in addons/default/themes. Ok this work because i can see it in CP.

Next i create a custom module with code :

class Server extends Public_Controller
{
public function __construct()
{
parent::__construct();

}
public function index()
{
$this->template->title($this->module_details['name'])->set_theme('uni')->build('test');

}
}

But when i browser this module, theme still is active theme on CP, so set_theme in module controller does not work.

Any way to make module using custom theme instead of change the active theme in CP?

tieungao
  • 45
  • 1
  • 3

2 Answers2

0

I think that to change the "theme" on the front-end you need to use a custom page layout, not the set_theme

Christian Giupponi
  • 7,408
  • 11
  • 68
  • 113
  • In pyrocms you can set only one theme for the front-end but you can also set a different layout via CP. http://www.pyrocms.com/docs/2.0/theming-pyrocms/theme-layouts – Christian Giupponi May 21 '12 at 17:29
  • yes i got your idea. But this abit messy if you have two theme and put to one with 2 layout files. I mention here is two diffrerent theme not only different in page layout. – tieungao May 22 '12 at 10:21
0

If i have understood your question then this question is similar to PyroCMS - custom module design, clear CSS formating from default design and you can find solution there.

Edited Going through your explanation, i think you want to use two different layouts for the same module. I actually don't know how to do it in controller but i can hard code it. Actually the layout is loaded in /system/appname/libraries/Template.php so you can solve it by hard coding here. Here is the solution i have made in pyroCMS 1.3.2, it might be similar to version 2.1 or you can get some hints in solving your problem.

File to change /system/appname/libraries/Template.php. Find build function and find the condition and replace it.

if ($this->_layout)
{
    // Added to $this->_data['template'] by refference
    $template['body'] = $this->_body;
            $CI = &get_instance();

            if($CI->uri->segment(2) == 'backend'){
                    $this->_body =  self::_load_view('layouts/backend.html', $this->_data, TRUE, self::_find_view_folder());
            }
            else{
                    $this->_body =  self::_load_view('layouts/frontend.html', $this->_data, TRUE, self::_find_view_folder());
            }
    }
Community
  • 1
  • 1
uttam
  • 589
  • 2
  • 7
  • 33
  • thank uttam, but let me explain again my question, i want to create one module call backend (with backend theme) and frontend module (with frontend theme). if set_theme work in custom module, everything will be okie because i just need create two custom theme, and at backend module i call set_theme('backend') and in frontend module i call set_theme('frontend') – tieungao May 22 '12 at 10:38
  • what i mean here is i have 2 custom modules and each module using one themes. Ty for this code but this is just for change layout file at CP and this is easy to do at 2.1 because set_layout work ok. What i concern is : theme has layout files, partial files and also css,js, image related. so if must using two layouts file at one theme, mean that you must mix two set of "img,js,css" to one theme directory and this a bit messy, rite? – tieungao May 22 '12 at 16:52