This is _VERY_ confusing, and I just went through it.
The form to search.cgi _should_ pass a 'substring' parameter either as a radio user-select option, or a hidden 'default' option.
If it doesn't, you can use:
(! defined $in->param('substring')) ? ($substring = 1) : (
;
To default to "yes, search substrings" or
(! defined $in->param('substring')) ? ($substring = 0) : (
;
to default to "no, search substrings".
If $in->param('substring') _is_ defined, you've passed in either a 1 or a 0 and you need to process it! If it's NOT defined, you can set your default by the above.
If you _DID_ pass in a value, as a radio or hidden field, you need to process it -- but it it does a 'flip-flop' in logic.
In the templates, you want to use "substring=1" for "yes, search substrings" or "substring=0" for "no, don't search substrings"
_BUT_ in the search.cig this is changed at the top, when the 'substring' input is altered to 'ww'.
Code:
($in->param('substring')) ? ($ww = 0) : ($ww = 1);
"ww" is "whole word" which is the logical OPPOSIT of "substring" (if _not_ substring then ww, if substring then _not_ ww)
So, to search on PARTIAL WORDS (substrings) you need to pass 'substring=1' to the search.cgi then set 'ww'= 0 for "no, don't search on whole words"
This is actually clearer in some respects when designing templates, but creates a "double negative" problem in program logic.
I changed several sites over to using 'ww' and got rid of 'substring' as the passed parameter.
I also added:
Code:
($in->param('ww')) ? ($ww = 1) : ($ww = 0);
To the list to process 'ww' if passed in. NOTE: if $in->param('ww') is 1, then $ww=1, if it's 0 then $ww=0.
This is the _opposite_ of 'substring'
******
****** If any of this is wrong, let me know so I can edit!
****** I'd like to add this to the FAQ since it's an endless source of confusion
******