문제

I am using CodeIgniter and I have a controller called contact which passes data to it's view which I have loaded in via the header so that it's on every page, however the data I pass to this view doesn't appear. It only appears if I go straight to the view via the url and I can only presume that this is caused because it is pulled in via another view which has a different controller? Is that right, if so how do I fix it?

For example:

<body>
  <div id="header">
    <h1>Hello there!</h1>
    <?php echo $this->load->view('contact'); ?>
  </div>
도움이 되었습니까?

해결책 2

the problem is calling the 'contact' view from another view doesn't mean the 'contact' controller is being called... that is why you are unable to access the data passed from the 'contact' controller!

To call controller from views you will need https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc

다른 팁

Are you parsing any data to the 'contact' view? If so, how?

CodeIgniter Userguide - Loading a View

function contact()
{
    $data['someinfo'] = "Some Info";
    $this->load->view('contact', $data);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top