You are here

README.txt in Views Contextual Range Filter 7

Same filename and directory in other branches
  1. 8 README.txt
VIEWS CONTEXTUAL RANGE FILTER (D7)
==================================

This is a simple plugin for Views that adds the option to contextually filter
a view not just by a single value, but also by RANGE.

Numeric (float, integer) and alphabetical (string) ranges are supported, as
well as lists.

Taxonomy term ids, node ids etc are special cases of integers so will work also.

The node date PROPERTIES (i.e. created, last updated dates) are also supported
by this module. Other dates, i.e. Date FIELDS (as in the Date module) are
supported by the Date Views submodule that comes with the Date project. However
the Date module does not support relative dates and natural language phrases
such as "last month", "4 days ago" or "today noon". If you wish to use these,
you DO need this Views Contextual Range Filter. In that case you may disable
Date Views.

You may use the OR ('+') and the negate operators. You negate by ticking the
"Exclude" box on the Views Contextual filter configuration panel, in the "More"
section.

Just like normal contextual filters, contextual range filters may be set by
appending filter values to the URL. Alternatively, if you want to use a UI,
install the "Views Global Filter" module:
http://drupal.org/project/global_filter.
This then enables a variety of widgets for you to enter your filter ranges,
text fields as well as range sliders. For the latter checkout the "Slide with
Style" module, http://drupal.org/project/select_with_style.
Views Global Filter provides the added benefit of it remembering your latest
contextual filter selections across multiple views for the duration of your
session, and even after logout.

To create a contextual range filter, first create a plain contextual filter as
per normal. I.e. in the Views UI open the "Advanced" field set (upper right) and
click "add" next to the heading "Contextual filters". On the next panel select
the field or property that needs to be contextually filtered and "Apply".
If you want to take advantage of Views Global Filter, then the next panel is
where you press the "Provide default value" radio button to select the
appropriate Global Filter option.
If you don't use a global filter you may pick any of the other options. For
instance for dates of content creation and modification you may opt to allow
relative dates in your ranges, so you can use phrases like "six months ago",
"yesterday", "today noon" and "last Monday of July".
Fill out the remainder of the configuration panel, press "Apply" and "Save" and
save the view.

Now visit the Contextual Range Filter configuration page,
admin/config/content/contextual_range_filter, find your contextual filter name
and tick the box next to it, to turn it into a contextual range filter. Press
"Save configuration".

If you don't use the Views Global Filter widgets, then you set your contextual
filters by appending "arguments" to the view's URL. Using the double-hyphen '--'
as a range separator, you can filter your view output like so:

  http://yoursite.com/yourview/100--199.99  (numeric range)
  http://yoursite.com/yourotherview/k--qzz  (alphabetical range)
  http://yoursite.com/somebodysview/3 months ago--yesterday (date range, using relative dates)
  http://yoursite.com/somebodysview/3--6    (list range, using list keys)
  http://yoursite.com/somebodysview/child--middle-aged (list range, using names)

For lists you may use either the keys or the RHS names in the allowed values
list on the Field settings page,
admin/structure/types/manage/<content-type>/fields/<field-type>/field-settings.
Example:

  1|Baby
  2|Toddler
  3|Child
  4|Teenager
  5|Adult
  6|Middle-aged
  7|Retiree

The list range order is the order of the allowed values. As far as the
Contextual Range Filter module is concerned list keys need not be consecutive.
However, if you wish to use the Slide with Style range slider widget, the list
keys must be integers with an increment of 1.

All ranges are inclusive of "from" and "to" value.

Strings will be CASE-INSENSITIVE, unless your database defaults otherwise. In
your database's alphabet, numbers and special characters (@ # $ % etc.)
generally come before letters , e.g. "42nd Street" comes before "Fifth Avenue"
and also before "5th Avenue". The first printable ASCII character is the space
(%20). The last printable ASCII character is the tilde '~'. So to make sure
everything from "!Hello" and "@the Races" up to and including anything starting
with the letter r is returned use " --r~".

You may omit the start or end values to specify open-ended filter ranges:

  http://yoursite.com/yourview/100--

Multiple contextual filters (eg Title followed by Price) are fine and if you
ticked "Allow multiple ranges" also, you can use the plus sign to OR filter
ranges like this:

  http://yoursite.com/yourthirdview/a--e~+k--r~/--500

Or, if your view has "Glossary mode" is on, so that only the first letter
matters, the above becomes:

  http://yoursite.com/yourthirdview/a--e+k--r/--500

You may use a colon ':' instead of the double hyphen.
Use either '--', ':' or 'all' to return all View results for the associated
filter:

  http://yoursite.com/yourthirdview/all/-100--999.99

To see how Views processes your contextual filter ranges and passes them on to
the database, tick the box "Show the SQL query" on page
admin/structure/views/settings. This can be particularly revealing when
experimenting with date ranges.

ASCII AND UTF CHARACTER ORDERING
o http://en.wikipedia.org/wiki/UTF-8

WORDS AND PHRASES ALLOWED IN RELATIVE DATES
o http://au2.php.net/manual/en/datetime.formats.relative.php

File

README.txt
View source
  1. VIEWS CONTEXTUAL RANGE FILTER (D7)
  2. ==================================
  3. This is a simple plugin for Views that adds the option to contextually filter
  4. a view not just by a single value, but also by RANGE.
  5. Numeric (float, integer) and alphabetical (string) ranges are supported, as
  6. well as lists.
  7. Taxonomy term ids, node ids etc are special cases of integers so will work also.
  8. The node date PROPERTIES (i.e. created, last updated dates) are also supported
  9. by this module. Other dates, i.e. Date FIELDS (as in the Date module) are
  10. supported by the Date Views submodule that comes with the Date project. However
  11. the Date module does not support relative dates and natural language phrases
  12. such as "last month", "4 days ago" or "today noon". If you wish to use these,
  13. you DO need this Views Contextual Range Filter. In that case you may disable
  14. Date Views.
  15. You may use the OR ('+') and the negate operators. You negate by ticking the
  16. "Exclude" box on the Views Contextual filter configuration panel, in the "More"
  17. section.
  18. Just like normal contextual filters, contextual range filters may be set by
  19. appending filter values to the URL. Alternatively, if you want to use a UI,
  20. install the "Views Global Filter" module:
  21. http://drupal.org/project/global_filter.
  22. This then enables a variety of widgets for you to enter your filter ranges,
  23. text fields as well as range sliders. For the latter checkout the "Slide with
  24. Style" module, http://drupal.org/project/select_with_style.
  25. Views Global Filter provides the added benefit of it remembering your latest
  26. contextual filter selections across multiple views for the duration of your
  27. session, and even after logout.
  28. To create a contextual range filter, first create a plain contextual filter as
  29. per normal. I.e. in the Views UI open the "Advanced" field set (upper right) and
  30. click "add" next to the heading "Contextual filters". On the next panel select
  31. the field or property that needs to be contextually filtered and "Apply".
  32. If you want to take advantage of Views Global Filter, then the next panel is
  33. where you press the "Provide default value" radio button to select the
  34. appropriate Global Filter option.
  35. If you don't use a global filter you may pick any of the other options. For
  36. instance for dates of content creation and modification you may opt to allow
  37. relative dates in your ranges, so you can use phrases like "six months ago",
  38. "yesterday", "today noon" and "last Monday of July".
  39. Fill out the remainder of the configuration panel, press "Apply" and "Save" and
  40. save the view.
  41. Now visit the Contextual Range Filter configuration page,
  42. admin/config/content/contextual_range_filter, find your contextual filter name
  43. and tick the box next to it, to turn it into a contextual range filter. Press
  44. "Save configuration".
  45. If you don't use the Views Global Filter widgets, then you set your contextual
  46. filters by appending "arguments" to the view's URL. Using the double-hyphen '--'
  47. as a range separator, you can filter your view output like so:
  48. http://yoursite.com/yourview/100--199.99 (numeric range)
  49. http://yoursite.com/yourotherview/k--qzz (alphabetical range)
  50. http://yoursite.com/somebodysview/3 months ago--yesterday (date range, using relative dates)
  51. http://yoursite.com/somebodysview/3--6 (list range, using list keys)
  52. http://yoursite.com/somebodysview/child--middle-aged (list range, using names)
  53. For lists you may use either the keys or the RHS names in the allowed values
  54. list on the Field settings page,
  55. admin/structure/types/manage//fields//field-settings.
  56. Example:
  57. 1|Baby
  58. 2|Toddler
  59. 3|Child
  60. 4|Teenager
  61. 5|Adult
  62. 6|Middle-aged
  63. 7|Retiree
  64. The list range order is the order of the allowed values. As far as the
  65. Contextual Range Filter module is concerned list keys need not be consecutive.
  66. However, if you wish to use the Slide with Style range slider widget, the list
  67. keys must be integers with an increment of 1.
  68. All ranges are inclusive of "from" and "to" value.
  69. Strings will be CASE-INSENSITIVE, unless your database defaults otherwise. In
  70. your database's alphabet, numbers and special characters (@ # $ % etc.)
  71. generally come before letters , e.g. "42nd Street" comes before "Fifth Avenue"
  72. and also before "5th Avenue". The first printable ASCII character is the space
  73. (%20). The last printable ASCII character is the tilde '~'. So to make sure
  74. everything from "!Hello" and "@the Races" up to and including anything starting
  75. with the letter r is returned use " --r~".
  76. You may omit the start or end values to specify open-ended filter ranges:
  77. http://yoursite.com/yourview/100--
  78. Multiple contextual filters (eg Title followed by Price) are fine and if you
  79. ticked "Allow multiple ranges" also, you can use the plus sign to OR filter
  80. ranges like this:
  81. http://yoursite.com/yourthirdview/a--e~+k--r~/--500
  82. Or, if your view has "Glossary mode" is on, so that only the first letter
  83. matters, the above becomes:
  84. http://yoursite.com/yourthirdview/a--e+k--r/--500
  85. You may use a colon ':' instead of the double hyphen.
  86. Use either '--', ':' or 'all' to return all View results for the associated
  87. filter:
  88. http://yoursite.com/yourthirdview/all/-100--999.99
  89. To see how Views processes your contextual filter ranges and passes them on to
  90. the database, tick the box "Show the SQL query" on page
  91. admin/structure/views/settings. This can be particularly revealing when
  92. experimenting with date ranges.
  93. ASCII AND UTF CHARACTER ORDERING
  94. o http://en.wikipedia.org/wiki/UTF-8
  95. WORDS AND PHRASES ALLOWED IN RELATIVE DATES
  96. o http://au2.php.net/manual/en/datetime.formats.relative.php