CodeIgniter Forums

Full Version: Multiple Template
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello all
i want to ask about how can posible we build template system like wordpress template.
so user can make their own template and just upload it the file to the backend
Hello,

Maybe you can do something like this :

application/core/MY_Controller.php
PHP Code:
class MY_Controller extends CI_Controller
{
 
   /**
     * @param string $view - 
     * @param string $title -
     * @param array $params - 
     */
 
   public function view($view$title$params null)
 
   {
 
       $this->load->model('comment_model');
 
       $params['title'] = $title;
 
       $params['output'] = $this->load->view($view$paramstrue);

 
       // Here you can choose different like a template
 
       $this->load->view('front'$params);
 
   }


application/views/front.php
PHP Code:
<html>
...
<?=
$output?>
...
</html> 

application/controllers/Your_controller.php
PHP Code:
class Your_controller extends MY_Controller
{
 
   public function index() {
 
       $this->view('welcome''Welcome');
 
   }

Hello
Example 
PHP Code:
$config['template_dir'] = 'my_design'

In back end select template dir

In controller
PHP Code:
$data['content'] = $this->load->view($template_dir '/page_tpl'$datatrue);