Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions

bugfix: boolean logic support in templates


3 Posts   971 Views


29 April 2011 at 3:45am (Last edited: 29 April 2011 3:47am), Community Member, 7 Posts

Hi team,

The SSViewer falls over when encountering some AND/OR boolean logic in the template. The PHP generated will break the parser.

This can be fixed in SSViewer::parseTemplateContent():

by changing line 543:
$content = ereg_replace('<' . '% +else_if +([A-Za-z0-9_]+) *\\|\\|? *([A-Za-z0-9_]+) +%' . '>', '<? else_if($item->hasValue("\\1") || $item->hasValue("\\2")) { ?>', $content);

$content = ereg_replace('<' . '% +else_if +([A-Za-z0-9_]+) *\\|\\|? *([A-Za-z0-9_]+) +%' . '>', '<? } else if($item->hasValue("\\1") || $item->hasValue("\\2")) { ?>', $content);

and changing line 547:
$content = ereg_replace('<' . '% +else_if +([A-Za-z0-9_]+) *&&? *([A-Za-z0-9_]+) +%' . '>', '<? else_if($item->hasValue("\\1") && $item->hasValue("\\2")) { ?>', $content);

$content = ereg_replace('<' . '% +else_if +([A-Za-z0-9_]+) *&&? *([A-Za-z0-9_]+) +%' . '>', '<? } else if($item->hasValue("\\1") && $item->hasValue("\\2")) { ?>', $content);

Cheers, Matt


30 April 2011 at 1:40am (Last edited: 30 April 2011 1:42am), Forum Moderator, 5511 Posts

Hi Matt,

Could you provide a series of unit test scripts for this or show that it's covered by existing tests. Does your change break any existing tests?

The status of 2.4.x is that it's only really critical or security issues getting through. There may be an intermediate 2.5 release before 3.0 which could include fixes such as this but we would not want to introduce any bugs of course (hence the tests!). SSViewer has been completely overhauled in master so hopefully should already be fine in that!

FYI any changes, bugfixes or other patches should be submitted via github. See for more information.


26 July 2011 at 10:13pm Community Member, 14 Posts

It was only a matter of remove the undescore from "else_if" to transform it in the correct PHP's "else if"

Thanks :P