Last active
July 25, 2017 10:58
-
-
Save teknosains/dd8ead39d7c0a97ac96ee42bd9c7f68e to your computer and use it in GitHub Desktop.
Calling layout from controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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