Created
April 1, 2014 21:28
-
-
Save psychobunny/9923582 to your computer and use it in GitHub Desktop.
[nodebb-script-category-dropdown] Category Dropdown Widget for NodeBB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="category-selector" style="position: relative"> | |
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown" type="button">Categories <span class="caret"></span></button> | |
<ul class="dropdown-menu" aria-labelledby="category-selector"> | |
</ul> | |
</div> | |
<br /> | |
<script> | |
// If you're using the custom homepage mod, switch the api call to /api/forum | |
$.get(RELATIVE_PATH + '/api/home', {}, function(data) { | |
var categories = data.categories | |
for (var c in categories) { | |
if (categories.hasOwnProperty(c)) { | |
var category = categories[c]; | |
$('#category-selector .dropdown-menu').append('<li role="presentation"><a role="menuitem" tabindex="-1" href="category/' + category.slug + '"><i class="fa ' + category.icon + '" style="color: ' + category.bgColor + '"></i> ' + category.name + '</a></li>'); | |
} | |
} | |
}); | |
</script> |
You are missing {relative_path}
before the href="category/'
So it should be; href="{relative_path}/category/'
But hey, it looks good! Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For more information aabout this widget, see here: https://community.nodebb.org/topic/1171/nodebb-script-category-dropdown-category-dropdown-widget