Question

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>
Was it helpful?

Solution 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

OTHER TIPS

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);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top