CodeIgniter Forums

Full Version: Template write_view : Undefined variable
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]dudzartiaga[/eluser]
I just used CodeIgniter for the first week and I encountered this error and can't figured out how to solve it.

I used Template class to create a master page but CI gives me this error.

A PHP Error was encountered
Severity: Notice
Message: Undefined variable: mymail
Filename: footerpage.php

Line Number: 2

Here my controller function:
public function index()
{
$data = array('mymail' => '[email protected]');
$this->template->write('title', 'My Title');
$this->template->write_view('header', 'headerpage', TRUE);
$this->template->write_view('content', contentpage', TRUE);
$this->template->write_view('footer', 'footerpage', $data, TRUE);
$this->template->render();
}

Everything is rendered perfectly except for the footer region. I created array of values, assigned it to $data, trying to pass it in footerpage.php but no luck.

Here's my footer's code:

<div class="footer">
<p>Made by &lt;?= $mymail ?&gt;</p>
</div>

What's wrong with my implementation?

Thank you in advance.