When displaying categorised views, restricted to a single category, on the web;
I noticed that if a category isn't there but a similar one is then that
category is displayed in error.
Say there is a category Docs41, but the url requests Docs4 by using the
&RestrictToCategory=Docs4 - Notes will provide the Docs41 category in the view.
To get around this, I put a computed for display field on my view template,
surrounded it with a <input type=hidden id=CorrectCategory value="cfd field">.
REM "@Contains will do partial matches too ie Doc4 exists within Doc41";
REM "Imploding the list with a * and checking for the key variable above will
only find Doc4 if Doc4* exists";
REM "Notes makes the same error when parsing the RestrictToCategory= parameter
in the Query String";
REM "Hence Doc41's documents can display when Doc4 is requested - this value is
for the javascript to check.";
@If(@Contains(list; key); "true"; "false")
The view template ensures that the view is surrounded by a table whose id we
know and a JavaScript function called onload, reads the value of the field and
if it reads 'false' then the view table is hidden and the error table, which
was defined initially with a style of display:none, is revealed.
When displaying categorised views, restricted to a single category, on the web; I noticed that if a category isn't there but a similar one is then that category is displayed in error.
Say there is a category Docs41, but the url requests Docs4 by using the &RestrictToCategory=Docs4 - Notes will provide the Docs41 category in the view.
To get around this, I put a computed for display field on my view template, surrounded it with a <input type=hidden id=CorrectCategory value="cfd field">.
cat:=@UpperCase(@Middle(@LowerCase(Query_String); "&restricttocategory="; "&")); lu:=@DbColumn("":"NoCache"; ""; "vwSMLinks"; 1); list:=@If(@IsError(lu); @Text(lu); @Implode(lu;"*")); key:=cat + "*";
REM "@Contains will do partial matches too ie Doc4 exists within Doc41"; REM "Imploding the list with a * and checking for the key variable above will only find Doc4 if Doc4* exists"; REM "Notes makes the same error when parsing the RestrictToCategory= parameter in the Query String"; REM "Hence Doc41's documents can display when Doc4 is requested - this value is for the javascript to check.";
@If(@Contains(list; key); "true"; "false")
The view template ensures that the view is surrounded by a table whose id we know and a JavaScript function called onload, reads the value of the field and if it reads 'false' then the view table is hidden and the error table, which was defined initially with a style of display:none, is revealed.