CodeIgniter Forums
Not Picking Up If Exist File - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Not Picking Up If Exist File (/showthread.php?tid=59594)



Not Picking Up If Exist File - El Forum - 10-25-2013

[eluser]razerone[/eluser]
I am just trying something new Not picking up file if exist

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

Code:
class Welcome extends CI_Controller {

public function index() {

  if (file_exists(APPPATH . 'views/theme/' . $filename)) {
      $this->load->view('theme/'.$filename);
  }
  else {
      $this->load->view('default/template/common/welcome_message.php');
  }
}
}



Not Picking Up If Exist File - El Forum - 10-25-2013

[eluser]razerone[/eluser]
I have got it working so far.

Code:
public function index() {

  if (file_exists('views/theme/')) {
      $this->load->view('theme'. $filename);
  }
  else {
      $this->load->view('/theme/default/template/common/welcome_message.php');
  }
}



Not Picking Up If Exist File - El Forum - 10-25-2013

[eluser]Otemu[/eluser]
where is $filename defined??
most likely your using the wrong path or wrong file name


Not Picking Up If Exist File - El Forum - 10-25-2013

[eluser]Tpojka[/eluser]
Maybe this can be solution:

Code:
public function index() {

  if (!$this->load->view('theme'. $filename)) {
      $this->load->view('/theme/default/template/common/welcome_message.php');
  }
}



Not Picking Up If Exist File - El Forum - 10-25-2013

[eluser]razerone[/eluser]
[quote author="Tpojka" date="1382699696"]Maybe this can be solution:

Code:
public function index() {

  if (!$this->load->view('theme'. $filename)) {
      $this->load->view('/theme/default/template/common/welcome_message.php');
  }
}
[/quote]

I also need to pass an array of couple of controllers not picking up must be done for something else what is codeigniter equilvent

$this->children = array(
'common/footer',
'common/header'
);