CodeIgniter Forums
Reverse Parsing (CI parser 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: Reverse Parsing (CI parser template) ?? (/showthread.php?tid=21586)



Reverse Parsing (CI parser template) ?? - El Forum - 08-14-2009

[eluser]rpe[/eluser]
Usually if we want to parse a variable, we need to define it first. Can we do the opposite way? Parsing first and define the variable later??

Example :
1.>This is what I usually do, I define the variable first, I put it in var.php.
Code:
class Example extends Controller{
function index(){
data['variable']=$this->load->view('variable','',TRUE);
$this->load->view('display');
}
}

then I use the variable in display.php
Code:
<html>
<head></head>
<body>
{variable}
</body>
</html>

2.>But, what I want is this, I use the variable first (in display.php)
Code:
<html>
<head></head>
<body>
{variable}
</body>
</html>

then I parse using this (var.php)
Code:
data[$var]=$this->load->view($var);

Thanks before.


Reverse Parsing (CI parser template) ?? - El Forum - 08-14-2009

[eluser]Phil Sturgeon[/eluser]
wtf?


Reverse Parsing (CI parser template) ?? - El Forum - 08-14-2009

[eluser]luke holder[/eluser]
[quote author="Phil Sturgeon" date="1250274509"]wtf?[/quote]

HAHAHAHAHAHA


Reverse Parsing (CI parser template) ?? - El Forum - 08-14-2009

[eluser]wabu[/eluser]
If I understand your post correctly, and that's really what you need to do, then you could just duplicate your first example with your "display" view, returning the output into a local variable for string substitution.

Then you can render your doubly-parsed template. Wink