![]() |
About Sub Template - 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: About Sub Template (/showthread.php?tid=56165) |
About Sub Template - El Forum - 11-30-2012 [eluser]Unknown[/eluser] Hello all, I have a question about two forms to do something that for me are the same: I have the next tree files, Controller.php Code: function lista(){ template.php Code: <h1>{titulo}</h1> usuarios_lista.php Code: {test} I can see the output in the browser: Code: <h1>Usuarios</h1> But the problem is when I want use PHP inside the html code: Controller.php Code: function lista(){ template.php Code: <h1><? echo $titulo;?></h1> usuarios_lista.php Code: <?echo $test;?> The code before said to me an error about test variable, that is unknown. Someone has an idea for solve this problem? Thanks in advanced ![]() About Sub Template - El Forum - 12-01-2012 [eluser]Aken[/eluser] When you load the usarios_lista view, you need to pass the "test" item through in the second parameter, where you currently have an empty array(). When you are using the template parser, the {test} item is not replaced until the template is loaded, so you don't need it when loading usarios_lista. However, when you want to use the raw PHP, usarios_lista needs that data since it is processed before the template. |