mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 10:01:40 -05:00
make category slug customizable
This commit is contained in:
parent
24a0f9b830
commit
e5c1b775af
1 changed files with 3 additions and 10 deletions
|
@ -18,7 +18,6 @@ categorySchema = new SimpleSchema({
|
|||
type: String,
|
||||
optional: true,
|
||||
autoform: {
|
||||
omit: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -27,15 +26,9 @@ Categories = new Meteor.Collection("categories");
|
|||
Categories.attachSchema(categorySchema);
|
||||
|
||||
Categories.before.insert(function (userId, doc) {
|
||||
doc.slug = slugify(doc.name);
|
||||
});
|
||||
|
||||
Categories.before.update(function (userId, doc, fieldNames, modifier, options) {
|
||||
// if body is being modified, update htmlBody too
|
||||
if (Meteor.isServer && modifier.$set && modifier.$set.name) {
|
||||
modifier.$set = modifier.$set || {};
|
||||
modifier.$set.slug = slugify(doc.name);
|
||||
}
|
||||
// if no slug has been provided, generate one
|
||||
if (!doc.slug)
|
||||
doc.slug = slugify(doc.name);
|
||||
});
|
||||
|
||||
// we want to wait until categories are all loaded to load the rest of the app
|
||||
|
|
Loading…
Add table
Reference in a new issue