Welcome Guest, Not a member yet? Register   Sign In
Parser and Render
#1

[eluser]Unknown[/eluser]
I'm new to using CI and were using it for one of our courses here at school.

Our current lab exercise requires we use the parser library and I am wondering how can i use it in-conjunction with $this->render();

currently we do:
Code:
$this->data['content'] = 'lab07_view';
$this->render();

Then I want lab07_view.php to look like
Code:
<table>
<tr>
<th>Blah</th><th>Blah2</th>
</tr>
{table}
<tr>
<td>{value1}</td>
<td>{value2}</td>
</tr>
{/table}
</table>

Seems fairly straight-forward right? But of course if i use $this->parser->parse('lab07_view', $data);
It won't load the template that normally loads when I just do the $this->render();

What do I need to look at to get the parser to work withing the existing render() function?

Wait... I think I just answered my question...

In ./core I have a MY_Controller.php that does the render() function and it calls
Code:
$this->parser->parse('_template', $this->data);

So is this the correct way to do this?
#2

[eluser]Unknown[/eluser]
Ah ok, I got it now..

Code:
$this->data = array_merge($this->data, $someArray);
$this->data['content'] = 'lab07_view';
$this->render();

Smile now I can parse the view properly!




Theme © iAndrew 2016 - Forum software by © MyBB