Skip to content

Instantly share code, notes, and snippets.

@prezire
Last active November 4, 2022 14:41
Show Gist options
  • Save prezire/795f52ca3702ee63e0a0 to your computer and use it in GitHub Desktop.
Save prezire/795f52ca3702ee63e0a0 to your computer and use it in GitHub Desktop.
Helps view rendering for CodeIgniter 3.
<?php
function showView($view, $data = null)
{
$CI = get_instance();
$CI->load->view('commons/layouts/header', $data);
$CI->load->view($view, $data);
$CI->load->view('commons/layouts/footer', $data);
}
function showJsonView($data, $status = 200)
{
exit($this->output
->set_status_header($status)
->set_content_type('application/json')
->set_output(json_encode($data))
->_display());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment