CSV and HTML search filter for WordPress

This is one of my WordPress plugins (HTML filter and csv-file search) made to add a simple ajax-search in html or in uploaded CSV-file.

The plugin has two shortcodes.

[ csvsearch src='/path/file.csv']
[ filtersearch search_element='table']

[ csvsearch ]

[ csvsearch ] is performing a search in an uploaded (or otherwise accessible) CSV-file. Use the format to set the output. use {0}, {1} etc for different columns in the file and {b}{/b}, {i}{/i} etc for simple formatting. Here is a sample with all arguments to use.

[ csvsearch 

// url to uploaded file
src='URL' 

// charset of file
charset='iso-8859-1' 

// format the output
format='{b}{0}{/b}, {1}, {2}{br/}'

// format the output with link
format="{a href='{0}'}{1}{/a}"

// format the output with image
format="{img src='{0}' /}"

// search label
searchtext='search' 

// format for output when instant search
instantformat='{0}' 

// instant search enabled or not
instantsearch='false' 

// data ID format, i.e. what to put in data-id of the listed element.
dataidformat="{0}" 

// change the item separator depending on type of csv file used
csv_separator=';'

// change the nothing found message
nothing_found_message='Nothing found when searching for: '

// If true, the shortcode will only find exact matches, case sensitive. 
// Default false.
exact_match='false'

// Add text where search-result will be placed. Default none.
placeholder_text='Place some default text before searching.'

// If you only want to search in one specific column you can specify this.
// If you only want to search in the first column you enter 0 here. 
// Remove this argument or add -1 to search in all columns.
only_search_in_column='2'

// To show the first line as a header you can set show_header_row to true.
// Use class 'hk_header_row' to style.
// Default is false.
show_header_row='true'

// Combine the show_header_row attribute with 
// headerformat attribute to set a specific style on the
// header (see format attribute to see how it works). Also
// you use the ignore_default_header_style='true' to remove
// the default style.

// Skip file check. Useful if WP installation is in sub 
// directory which is not working properly. Add this 
// argument to skip the file-checking. Default is false.
skip_file_check='true'

// Set focus in filter input element on page load
// Default is false.
set_focus_on_load='true'

]

Use this [ csvsearch ] shortcode

[ csvsearch 
src='/wp-content/uploads/2022/01/sample2.csv' 
searchtext='Search in file' 
format='{b}{0} {1}{/b} {2} - {3}{br/}' 
nothing_found_message='No hits for: '
show_header_row='true']

to show this search


for a search in this csv-sample-file. Try searching for a name (I’m using the same sample names as in the table above) or a favorite color (pink, blue, red, …) or lucky number (3, 6, 7, …) to see the results.

[ filtersearch ]

[ filtersearch ] does a filter inside current html page. Specify which element you want to search within. You cah use either element type, .class_name of #id. See sample below for more arguments that can be used.

[ filtersearch 

// what DOM element to search in, use element type, .class_name or #id
search_element='' // default to 'table'

// show table header or not when filtering
show_header_in_table='false'

// filter heading 
text='Page filter'

// class to style clear icon
clear_icon_class='delete-icon'

// clear filter text
clear_text='Clear' 

// Set focus in filter input element on page load
set_focus_on_load='true'
]

Use this [ filtersearch] shortcode

[ filtersearch 
search_element='#name_table' 
text='Filter name in table' 
show_header_in_table=true 
clear_text='Clear filter' 
set_focus_on_load=false]

which enables this filter

Filter name in tableClear filter

on this table (with id name_table)

First nameLast name
EmilySmith
EdithJohnson
JohnWilliams
SophiaBrown
RobertJones
PaulaGarcia
JamieMiller
RobertDavis
MartinaRodriguez
PabloMartinez

Download

Download the plugin from wordpress.org.

Feel free to donate if you find the plugin useful 🙂

Comments

Cart