Welcome Guest, Not a member yet? Register   Sign In
Pass a variable with html content into parser
#1

[eluser]Sara rad[/eluser]
Hi everyone

i have a variable with html content like it :

Code:
$data['usrename'] = 'sara';
$tpl = '<p style="color:red">{username}</p>';

how can i use this in parser library instead of a template file ?
#2

[eluser]Sara rad[/eluser]
this way workd but im looking for better way :


Code:
$data['content'] = '<p style="color:red;">Hi {username} , welcome to our site</p>';

$fh = fopen('application/views/file.tpl', 'w') or die("can't open file");    
fwrite($fh, $data['content']);
fclose($fh);

$data['username'] = 'sara';

$this->parser->parse('file.tpl',$data);
#3

[eluser]Sara rad[/eluser]
Any idea ?




Theme © iAndrew 2016 - Forum software by © MyBB