Since v1.7.1 introduced new, optimized template engine, a little bug was created which would not allow use conditional tags inside other conditional tags:
{if blah}{if blah2}...{endif blah2}{endif blah}
the
{if blah2}{endif blah2} would be ignored.
Also, in this fix I added new feature
{ifno blah}{endifno blah} type of conditional tags. That condition is opposite of
{if blah} meaning that code between these tags will be showed only if
{blah} tag is empty.
Open
includes/templates.phpFind:
// Compile condition tags
$template = preg_replace_callback(
'='.preg_quote($this->start).'if\s+([A-Z0-9_]+)'.preg_quote($this->end).'(.*)'.preg_quote($this->start).'endif\s+(\\1+)'.preg_quote($this->end).'=Usi',
array(&$this, '_compile_condition'),
$template
);
Replace it with:
// Compile condition tags
$template = preg_replace_callback(
'='.preg_quote($this->start).'if\s+([A-Z0-9_]+)'.preg_quote($this->end).'=Usi',
array(&$this, '_compile_condition_start'),
$template
);
$template = preg_replace_callback(
'='.preg_quote($this->start).'endif\s+([A-Z0-9_]+)'.preg_quote($this->end).'=Usi',
array(&$this, '_compile_condition_end'),
$template
);
$template = preg_replace_callback(
'='.preg_quote($this->start).'ifno\s+([A-Z0-9_]+)'.preg_quote($this->end).'=Usi',
array(&$this, '_compile_condition_no_start'),
$template
);
$template = preg_replace_callback(
'='.preg_quote($this->start).'endifno\s+([A-Z0-9_]+)'.preg_quote($this->end).'=Usi',
array(&$this, '_compile_condition_no_end'),
$template
);
Then find:
function _compile_condition(&$matches) {
return '<?php if (!empty($' . trim($matches[1]) . ') && $' . trim($matches[1]) . ' != REPLACE_EMPTY): ?>' . $matches[2] . '<?php endif; ?>';
}
Replace it with:
function _compile_condition_start(&$matches) {
return '<?php if (!empty($' . trim($matches[1]) . ') && $' . trim($matches[1]) . ' != REPLACE_EMPTY){ ?>';
}
function _compile_condition_end(&$matches) {
return '<?php } ?>';
}
function _compile_condition_no_start(&$matches) {
return '<?php if (empty($' . trim($matches[1]) . ') || $' . trim($matches[1]) . ' == REPLACE_EMPTY){ ?>';
}
function _compile_condition_no_end(&$matches) {
return '<?php } ?>';
}
P.S. if u dont need
{ifno ..} feature, then I think it wouldn't be too dificult to figure out what needed to be removed