Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[nodebb-script-category-dropdown] Category Dropdown Widget for NodeBB
<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>
@psychobunny

This comment has been minimized.

Copy link
Owner Author

@psychobunny psychobunny commented Apr 1, 2014

@cnvo

This comment has been minimized.

Copy link

@cnvo cnvo commented Apr 2, 2014

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
You can’t perform that action at this time.