Open orchardbot opened 9 years ago
anoordende commented:
Pull request: 7943
@Piedone commented:
Agree, but as a current workaround you could make use of the WrapNotEmpty token.
@sebastienros commented:
We talked about it today and we think that the result should be empty in this case: /search?bedrooms=
PR contains the recommended code
anoordende commented:
Updated PR, re-applied to latest 1.x source and updated to not override empty query/form parameter values.
Am just about to breathe new life into this issue with a PR.
anoordende created: https://orchard.codeplex.com/workitem/21166
RequestTokens are very powerful when used in conjunction with, for example, custom searches using Queries and Projections.
Problem It fails, however, when a querystring parameter is omitted. Sometimes this can be worked around, but, for example in the case of a number, the decimal parser in Projections chokes on the empty value with a FormatException.
Solution Allow an optional default value to be specified in the token, so that when a QueryString / Form Value is omitted (either only the value or entirely)
Examples Example of specifying a default value (for the example I have used a real-estate search): {Request.QueryString:bedrooms} // No default value {Request.QueryString:bedrooms,1} // A default value of "1"
Examples of querystrings that would work with a default specified: /search?bedrooms=2 // The value "2" is used /search?bedrooms= // The default value is used when specified in token /search // The default value is used when specified in token