filter slug for category update

v1.18.x
Nicolas Siver 10 years ago
parent 773d886135
commit 1e2f4ae5e9

@ -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();

Loading…
Cancel
Save