I am writing an application in CodeIgniter where I specify the
meta-tag on every page in every controller which I have managed to send to my header te
Create a base controller. The default location for this is application/core/MY_Controller.php =>
this can be changed via the config.
By using $this->site_data
you can add variables in your base class and use them in every controlle/view
class MY_Controller extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->database();
$this->load->model('your model');
$result = $this->Listing_model->get_card($card);
$this->site_data['query']=$result;
$this->site_data_header["page_title"] = $result['get the property you want'];//this is possible, as get_card returns 1 result
}
}
class YourClass extends MY_Controller
{
function __construct()
{
parent::__construct();
}
public function show($card = NULL)
{
//you don't need to split the variables
//for header and the rest
$this->load->view('includes/header',$this->site_data_header);
$this->load->view('listings/listing_card',$this->site_data);
$this->load->view('includes/footer');
}
}
And I think your get_where is wrong:
$query = $this->db->get_where('mytable', array('id' => $id), $limit, $offset);
your limit is 0
function get_card($card = FALSE)
{
$query = $this->db->get_where('creditcards', array('slug' => $card), 1,0);//limit 1 offset 0
return $query->result();
}
access the data in your view