Welcome Guest, Not a member yet? Register   Sign In
Quick Question
#1

Hallo,

I need some help to understand this CI code:

home.php


PHP Code:
$this->load->view($this->data['post_detail']->template_name$this->data); 



Where does this "template_name" comes from?

I wonder where does template_name being defined from?

I  am trying to understand where does this view pointing to?

Thanks in advance.
" If I looks more intelligence please increase my reputation."
Reply
#2

The template_name is a property of your $this->data['post_detail'] object. It should be assigned somewhere in your controller.
Reply
#3

Okay,  I am still tracing where "template_name" comes from?


home.php


PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class 
Home extends MY_Controller {
    
    var 
$data = array();
    
    public function 
__construct()
    {
        
parent::__construct();
    }
    
    public function 
index()
    {
        
$this->load->model('page_model');
        
$this->data['page_detail'] = $this->page_model->find_ID();
        
        
$this->page_model->counter($this->data['page_detail']->post_ID);
        
        
$this->data['post_list'] = $this->model->post($this->data['page_detail']->post_ID);
        
$this->data['gallery_list'] = $this->model->post($this->data['page_detail']->post_IDtrue);
        
        
$this->load->view($this->data['page_detail']->template_name$this->data);
    } 



application/core/MY_Controller.php

PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class 
MY_Controller extends CI_Controller {
    
    public function 
__construct()
    {
        
parent::__construct();
    }
    
    public function 
current_user()
    {
        return 
$this->memberlog->current();
    }
    
    public function 
signed_in()
    {
        return 
$this->memberlog->signed_in();
    }
    
    public function 
auth()
    {
        if ( ! 
$this->signed_in())
            
redirect();
    }

" If I looks more intelligence please increase my reputation."
Reply
#4

(This post was last modified: 02-15-2016, 05:39 AM by InsiteFX.)

(02-15-2016, 05:24 AM)davy_yg Wrote: Okay,  I am still tracing where "template_name" comes from?


home.php


PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class 
Home extends MY_Controller {
    
    var 
$data = array();
    
    public function 
__construct()
    {
        
parent::__construct();
    }
    
    public function 
index()
    {
        
$this->load->model('page_model');
        
$this->data['page_detail'] = $this->page_model->find_ID();
        
        
$this->page_model->counter($this->data['page_detail']->post_ID);
        
        
$this->data['post_list'] = $this->model->post($this->data['page_detail']->post_ID);
        
$this->data['gallery_list'] = $this->model->post($this->data['page_detail']->post_IDtrue);
        
        
$this->load->view($this->data['page_detail']->template_name$this->data);
    } 



application/core/MY_Controller.php

PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class 
MY_Controller extends CI_Controller {
    
    public function 
__construct()
    {
        
parent::__construct();
    }
    
    public function 
current_user()
    {
        return 
$this->memberlog->current();
    }
    
    public function 
signed_in()
    {
        return 
$this->memberlog->signed_in();
    }
    
    public function 
auth()
    {
        if ( ! 
$this->signed_in())
            
redirect();
    }


It's getting it from here!


PHP Code:
$this->data['page_detail'] = $this->page_model->find_ID(); 

Look in your Model then find the id and check your database that's where it is getting it.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB