Support Forums

The forums are closed and will be removed when we launch our new site.

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro Split Categories Alphabetically Index

Viewing 3 posts - 1 through 3 (of 3 total)
  • Konstantinos Riginos
    #53739

    Hi, this plugin is awesome!

    I couldn’t find an answer in this forum and as I am not a PHP expert maybe you could solve this for me.

    I am showing a list of my categories like so:

    I would like to index those categories into alphabetical sections like this:

    I found this plugin that does what I want but don’t know how to integrate it to S&F.

    Any help would be much appreciated!

    Thanking you in advance,

    Kostas

    Konstantinos Riginos
    #53742

    So I actually figured out a way to do that:

    In case anyone has this same question/problem just add this code:

    <script>
    var list = { letters: [] };
    jQuery(".sf-field-category > ul").children("li").each(function(){
      var itmLetter = jQuery(this).text().substring(0,1).toUpperCase();
      if (!(itmLetter in list)) {
        list[itmLetter] = [];
        list.letters.push(itmLetter);
      }
      list[itmLetter].push(jQuery(this));
    });
    list.letters.sort();
    jQuery(".sf-field-category > ul").empty();
    jQuery.each(list.letters, function(i, letter){
      list[letter].sort(function(a, b) {
        return jQuery(a).text().toUpperCase().localeCompare(jQuery(b).text().toUpperCase());
      });
      var ul = jQuery("<ul/>");
      jQuery.each(list[letter], function(idx, itm){
        ul.append(itm);
      });
      jQuery(".sf-field-category > ul").append(jQuery("<li/>").append(jQuery("<label/>").attr("name", letter.toLowerCase()).addClass("title").html(letter)).append(ul));
    });
    </script>
    Trevor Moderator
    #53767

    Thanks for sharing. I have tidied up the posts for you 😉

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Split Categories Alphabetically Index’ is closed to new replies.