Welcome Guest, Not a member yet? Register   Sign In
Multiple Template
#1

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
Reply
#2

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');
 
   }

Reply
#3

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); 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB