Guest User

Untitled

a guest
Jun 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2.  
  3. class Template
  4. {
  5. var $ci;
  6.  
  7. function __construct()
  8. {
  9. $this->ci =& get_instance();
  10. }
  11. function load($tpl_view, $body_view = null, $data = null)
  12. {
  13. if ( ! is_null( $body_view ) )
  14. {
  15. if ( file_exists( APPPATH.'views/'.$tpl_view.'/'.$body_view ) )
  16. {
  17. $body_view_path = $tpl_view.'/'.$body_view;
  18. }
  19. else if ( file_exists( APPPATH.'views/'.$tpl_view.'/'.$body_view.'.php' ) )
  20. {
  21. $body_view_path = $tpl_view.'/'.$body_view.'.php';
  22. }
  23. else if ( file_exists( APPPATH.'views/'.$body_view ) )
  24. {
  25. $body_view_path = $body_view;
  26. }
  27. else if ( file_exists( APPPATH.'views/'.$body_view.'.php' ) )
  28. {
  29. $body_view_path = $body_view.'.php';
  30. }
  31. else
  32. {
  33. show_error('Unable to load the requested file: ' . $tpl_name.'/'.$view_name.'.php');
  34. }
  35.  
  36. $body = $this->ci->load->view($body_view_path, $data, TRUE);
  37.  
  38. if ( is_null($data) )
  39. {
  40. $data = array('body' => $body);
  41. }
  42. else if ( is_array($data) )
  43. {
  44. $data['body'] = $body;
  45. }
  46. else if ( is_object($data) )
  47. {
  48. $data->body = $body;
  49. }
  50. }
  51.  
  52. $this->ci->load->view('templates/'.$tpl_view, $data);
  53. }
  54. }
Add Comment
Please, Sign In to add comment