Skip to content

Instantly share code, notes, and snippets.

@teknosains
Last active July 25, 2017 10:58
Show Gist options
  • Save teknosains/dd8ead39d7c0a97ac96ee42bd9c7f68e to your computer and use it in GitHub Desktop.
Save teknosains/dd8ead39d7c0a97ac96ee42bd9c7f68e to your computer and use it in GitHub Desktop.
Calling layout from controller
<?php defined('BASEPATH') or exit('No direct script access allowed');
/**
* Home class
* Check /core/MY_Controller
*
* @author budy k
* @link www.facebook.com/teknosains
* @link www.teknosains.com
*
*/
class Home extends MY_Controller
{
//......
/**
* Detail Article
* @param str slug
*/
public function read($slug = null)
{
$article = $this->Home_model->fetchDetail($slug);
//show 404 if no article found
if (!$article) {
show_404();
}
/**
* meta data to send to the View.
* add anything you want here
*/
$data = [
'meta' => [
'title' => $article['title'],
'Description' => trim(word_limiter(strip_tags($article['content']), 100))
],
'article' => $article
];
//Calling layout
$this->materialLayout($data, 'home/read');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment