made breadcrumbs regular function

less db calls as well
This commit is contained in:
barisusakli
2014-12-11 22:55:00 -05:00
parent 518c6f7cfa
commit 8965855218
5 changed files with 80 additions and 59 deletions

View File

@@ -123,6 +123,26 @@ topicsController.get = function(req, res, next) {
next(null, topicData);
});
},
function (topicData, next) {
var breadcrumbs = [
{
text: topicData.category.name,
url: nconf.get('relative_path') + '/category/' + topicData.category.slug
},
{
text: topicData.title,
url: nconf.get('relative_path') + '/topic/' + topicData.slug
}
];
helpers.buildBreadcrumbs(topicData.category.parentCid, function(err, crumbs) {
if (err) {
return next(err);
}
topicData.breadcrumbs = crumbs.concat(breadcrumbs);
next(null, topicData);
});
},
function (topicData, next) {
var description = '';
@@ -245,7 +265,6 @@ topicsController.get = function(req, res, next) {
}
}
data.breadcrumbs = res.locals.breadcrumbs;
res.render('topic', data);
});
};