Pages.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php namespace App\Controllers;
  2. use CodeIgniter\Controller;
  3. use CodeIgniter\I18n\Time;
  4. class Pages extends BaseController
  5. {
  6. protected $logic1;
  7. protected $logic2;
  8. protected $myTime;
  9. public function __construct()
  10. {
  11. parent::__construct();
  12. $this->myTime = parent::getTime();
  13. $this->myDate= date("d/m/Y",$this->myTime);
  14. }
  15. public function index()
  16. {
  17. echo $this->request->getVar('title');
  18. //return view('welcome_message');
  19. }
  20. public function showme($page = 'home')
  21. {
  22. $this->cachePage(DAY);
  23. $this->logic1= file_exists(APPPATH.'/Views/'.$page.'.php');
  24. if(( $this->logic1 == NUll)OR ($this->logic1 == False))
  25. {
  26. return redirect('noPage');
  27. }
  28. elseif(($this->logic1==1)OR($this->logic1==true))
  29. {
  30. $data = [
  31. 'title' =>ucfirst($page) ,
  32. 'date'=>$this->myDate
  33. ];
  34. echo view($page,$data);
  35. }
  36. }
  37. public function nopage()
  38. {
  39. $this->cachePage(DAY);
  40. $data = [
  41. 'title' => 'no page',
  42. //'result2'=>$result
  43. //above works
  44. 'date'=>$this->myDate
  45. ];
  46. echo view('noPage',$data);
  47. }
  48. }