Skip to content

Node.js based forum software built for the modern web

filter slug for category update

Nicolas Siver1e2f4ae5e931
diff --git a/src/categories/update.js b/src/categories/update.js
index f1d9ee773c..907def6875 100644
--- a/src/categories/update.js
+++ b/src/categories/update.js
@@ -16,7 +16,14 @@ module.exports = function(Categories) {
return next(err);
}
- plugins.fireHook('filter:category.update', modified[cid], function(err, category) {
+ var modifiedFields = modified[cid];
+
+ if(modifiedFields.hasOwnProperty('name')){
+ modifiedFields.slug = cid + '/' + utils.slugify(modifiedFields.name);
+ }
+
+ plugins.fireHook('filter:category.update', {category:modifiedFields}, function(err, categoryData) {
+ var category = categoryData.category;
var fields = Object.keys(category);
async.each(fields, function(key, next) {
updateCategoryField(cid, key, category[key], next);
@@ -44,10 +51,7 @@ module.exports = function(Categories) {
return callback(err);
}
- if (key === 'name') {
- var slug = cid + '/' + utils.slugify(value);
- db.setObjectField('category:' + cid, 'slug', slug, callback);
- } else if (key === 'order') {
+ if (key === 'order') {
db.sortedSetAdd('categories:cid', value, cid, callback);
} else {
callback();