Providing a way to filter through homebox-add blocks

Created on 7 July 2014, almost 10 years ago
Updated 16 October 2023, 9 months ago

Unsure if this is necessary but I feel it would be nice if there was a feature to filter out the blocks available that people can see based on the user's input. I know there are ways to filter through roles and permissions, but for a project I am working on, we want the user to have access to all content but still not have to scroll through a ridiculous amount of blocks to find what he/she is looking for. Is there something like this that already exists?

For now, I simply used this code so feel free to use it. It simply uses JQuery to hide things based on the search option. Please note, you'll need to create a block, or an input with an id of "homebox_search" in order for this to work.

I included a JS file in my site to include the following code:

$(document).ready(function() {
      //Homebox search code that filters through all the homebox-add blocks
	  $('#homebox_search').keyup(function() {
	    var valThis = $(this).val().toLowerCase();
	    $('#homebox-add li').each(function(){
	      var text = $(this).text().toLowerCase();
	      console.log(text + " " + text.indexOf(valThis));
	      (text.indexOf(valThis) > -1) ? $(this).show() : $(this).hide();            
	    });
	  });
	});

If there is a better solution, perhaps people can include it.

✨ Feature request
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States augbog

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024