[eluser]Kriesi[/eluser]
[quote author="Jondolar" date="1258075252"]I would have thought that if the array variable was set but blank it would remove it but I don't use the built-in parser. Can you just replace the "missing" variable with an HTML comment like <!-- --> so it won't show up in the rendered page? A better option might be to modify the temlate parser and make it work properly.[/quote]
Well actually thats the case, if you set the string to $data[$my_var] = ""; it wont display. the problem I have is that I dont know which variables to set to empty (its a site with multiple languages and some of the content only gets displayed for some of the languages)
the solution I came up with is to check which variables are within the template before parsing and setting everything to empty, then make a database query and merge the 2 arrays so that all empty values that now have a value get overriden:
Code:
$template = $this->load->view('index', '', true);
preg_match_all('/\{(\w+)\}/', $template, $matches);
if($matches[1])
{
foreach($matches[1] as $value)
{
$blankdata[$value] = "";
}
}
$data = //database query here;
$data = array_merge((array)$blankdata, (array)$data;
$this->parser->parse('index',$data);