mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 22:15:48 +01:00
made breadcrumbs regular function
less db calls as well
This commit is contained in:
@@ -172,6 +172,21 @@ categoriesController.get = function(req, res, next) {
|
||||
function(payload, next) {
|
||||
categories.getCategoryById(payload, next);
|
||||
},
|
||||
function(categoryData, next) {
|
||||
var breadcrumbs = [
|
||||
{
|
||||
text: categoryData.name,
|
||||
url: nconf.get('relative_path') + '/category/' + categoryData.slug
|
||||
}
|
||||
];
|
||||
helpers.buildBreadcrumbs(categoryData.parentCid, function(err, crumbs) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
categoryData.breadcrumbs = crumbs.concat(breadcrumbs);
|
||||
next(null, categoryData);
|
||||
});
|
||||
},
|
||||
function(categoryData, next) {
|
||||
if (categoryData.link) {
|
||||
return res.redirect(categoryData.link);
|
||||
@@ -243,7 +258,6 @@ categoriesController.get = function(req, res, next) {
|
||||
}
|
||||
}
|
||||
|
||||
data.breadcrumbs = res.locals.breadcrumbs;
|
||||
res.render('category', data);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user