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 /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

bugfix: boolean logic support in templates

Go to End

3 Posts   1392 Views


Community Member, 7 Posts

29 April 2011 at 3:45am

Edited: 29/04/2011 3:47am

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


Forum Moderator, 5523 Posts

30 April 2011 at 1:40am

Edited: 30/04/2011 1:42am

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.


Community Member, 14 Posts

26 July 2011 at 10:13pm

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

Thanks :P