Params
attributes
(Object) – The custom attributes and their values of the new CMS object.
Throws
ArgumentError
– If a given attribute is invalid.
Returns
The created Obj
.
Examples
Creates a new Obj
with the given attributes
.
Scrivito.getClass("BlogPost").create({ title: "Hello world!" })
Params
attributes
(Object) – The custom attributes and their values of the new CMS object.Throws
ArgumentError
– If a given attribute is invalid.Returns
The created Obj
.
Examples
Create a new blog post with a permalink:
Scrivito.getClass("BlogPost").create({
_permalink: "scrivito-best-practices",
title: "How to Make the Best of Scrivito",
});
Be aware that setting a permalink this way (as opposed to setting it using the UI’s permalink editor) does not check whether the permalink is already in use.
Create a new page consisting of an initial text widget that says “Hello!”. After creating the page, navigate to the new page:
Page = Scrivito.getClass('Page');
TextWidget = Scrivito.getClass('TextWidget');
widget = new TextWidget({ text: 'Hello!' });
obj = Page.create({ body: [widget] });
Scrivito.navigateTo(obj);