Webmastersite.net

Search    Register    Log In   

Details

Safer Conditionals
By
Jun 04, 2015 pm30 6:42 PM (Edited )

Found a nice tool called browsera for detecting javascript errors and layout problems that are specific to Internet Explorer.

Most of the time, WSN's template conditionals make things easy. There's a long-standing annoying case where they're buggy, though: checking whether a complex HTML field contains a term. Suppose you want to do <IF {LINKDESCRIPTION} contains widget>This listing mentions a widget</IF>. If the description has HTML tags, the conditional can error because the closing tags in the HTML are taken as closing the conditional. Worse yet, if you've enabled search highlighting even simple text can become HTML on the search results page. When someone searches for widget, 'widget' is replaced on the page with <span class="searchhighlight">widget</span> in order to highlight the searched word and this causes the same HTML comparison problem. One workaround for that is to exclude any fields you compare that way from search highlighting, but that's not ideal and it's hard to notice and catch the problem.

In order to have a safer way to do these sorts of comparisons, I'm introducing an optional new syntax {LINKVARCOMPARE[description <,> contains <,> text]}. You'll be able to safely write the conditional as <IF {LINKVARCOMPARE[description <,> contains <,> widget]}>. The first parameter is the template variable name, the second parameter is the operator, the third is the needle. The operators names are the same as in the conditionals syntax: is, is not, contains, does not contain, greater than and less than.

This new syntax will be available soon in both 9.1 and 9.2.




Tags
Views 175 views. Averaging 175 views per day.

Sorry, you don't have permission to post. Log in, or register if you haven't yet.

Please login or register.