Knowledge Base - Tutorial Interval search plugin for Sobi2

The search method "From... - To..." allows you to search all entries between the values entered. For example, for 2, 4, 5, 6, 8, 10, a search for values returned from 5-9 are 5, 6, 8.

Simple values

In the case of values of type inputbox, open the tab "Between method" and choose the minimum required parameters:

  • - The choice of custom fields: Select the fields that you want to search the values. In our example we will work on the field field_code order to search entries on their postcode.
  • - Method: We will select 'by value', in order to set ourselves values backend.
  • - From list: On our site example, the postal code range is from 1001 to 1950. We will split the list into several groups and without entering the last value: 1000,1200,1400,1600,1800.
  • - To list: Enter the same values, but without entering the first and, this time entering the last: 1200,1400,1600,1800,2000
  • - State: verify that the state is 'publish'.

plugin_interval8

Click the save button and all settings are saved, for example if you selected 'mark for deletion' for the 'state' parameter, this block shall have been removed.

And the frontend result is correct. If I select "From 1000 - To 1200", only the entry with the postal code 1001 appears.

plugin_interval9

ListBox values

The operation with the type of field listbox is the same. Simply choose a field type listbox. In our example it is the custom field 'field_height', which contains this kind of values 150 -> 150 cm, 160 -> 160 cm, 170 -> 170 cm, ... You can enter values in the same way, ie "From: 150, 160, 170, 180, 190" and "To: 160, 170, 180, 190, 200.

Or maybe there is another solution, simply enter a value in the 'Step' parameter, and the plugin automatically calculates the values to be placed in the drop-down lists. For example, entering a value of 5, the plugin inserts these values: "150, 155, 160, 165, 170, 175, 180, 185, 190, 195, 200.

plugin_interval10

Calendar values

With this type of field it is not possible to work with the 'Step' method, we must work with the 'By values' mode. In our example, the dates of the entries are ranged from 16.01.2009 to 17.12.2009 (dd.mm.yyyy). Including an example we can seize these dates for the inputs ' From... To... ': 01.01.2009, 01.02.2009, 01.03.2009, 01.04.2009, 01.05.2009, 01.06.2009, 01.07.2009, 01.08.2009, 01.09.2009, 01.10.2009, 01.11.2009, 12.01.2009, 01.01.2010.

plugin_interval11

Also in the same block 'Calendar', trying to change the mode from 'By values' to 'User Input'. In this case it is allowed to leave the values 'From ...' and 'To ..' previously entered, they are simply not used.

plugin_interval12

And now in the frontend, the form is different, the section 'From... To... ' is now designed as calendar input.

plugin_interval13

Advanced options

In the previous examples, we used three different methods of user input, it is of course possible to use each method with each type of custom fields (except from the step mode with fields of type calendar).

Draw One list: If you dont want use 2 listbox for the 'from... to...' selection, you can set this value to yes. Then if you have these values: From: 1,5,10,15 To: 5, 10, 15, 20 then the result list will be: 1 to 5, 5 to 10, 10 to 15, 15 to 20.

Tolerance: You can set a tolerance value. This value is in percent. If you set 10 here, a tolerance of 10% minus of the from value and 10% bigger of the to values is used to find the result. Then, a from 100$ to 200$ search will include prices from 90$ to 220$.

Number format: You can specify the number of decimals, the thousand separator and the comma. Then a number like 1976, can be drawn 1,976.00 or 1'976,0. The original value is not changed. If all 3 parameters are given, number  will be formatted with entered decimals, decimal separator instead of a dot (".") before the decimals and the entered thousands separator instead of a comma (",") between every group of thousands.

Applies To

All Products