Forums › Forums › Search & Filter Pro › Split Categories Alphabetically Index
Tagged: alphabetical, alphabetically, categories, index, split
- This topic has 2 replies, 2 voices, and was last updated 8 years, 3 months ago by Trevor.
Viewing 3 posts - 1 through 3 (of 3 total)
-
Anonymous(Private) August 7, 2016 at 11:18 pm #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
Anonymous(Private) August 8, 2016 at 12:49 am #53742So 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>
-
AuthorPosts
Viewing 3 posts - 1 through 3 (of 3 total)