Click or drag to resize

ISchemaManagerCreateSchema Method (String, String, Int32, Boolean, EnumPageSchemaType, String, String, IPagePresentationCollection, String)


Creates a new Schema. This can be either a page or component schema.

Namespace:  Ingeniux.CMS
Assembly:  Ingeniux.CMS.CSAPI (in Ingeniux.CMS.CSAPI.dll) Version: 10.6.308
Syntax
ISchema CreateSchema(
	string name,
	string friendlyName,
	int icon,
	bool isComponent,
	EnumPageSchemaType pageSchemaType,
	string viewName = "",
	string stylesheet = "",
	IPagePresentationCollection presentations = null,
	string thumbnailPath = ""
)

Parameters

name
Type: SystemString
The new schema's root element name. This must be a valid XML element name.
friendlyName
Type: SystemString
The new schema's friendly name. This can be any name you choose, but it's recommended that you limit its length.
icon
Type: SystemInt32
An icon ID, which corresponds to an icon image.
isComponent
Type: SystemBoolean
If true, the schema creates a component. If false, it creates a page.
pageSchemaType
Type: Ingeniux.CMS.EnumsEnumPageSchemaType

[Missing <param name="pageSchemaType"/> documentation for "M:Ingeniux.CMS.ISchemaManager.CreateSchema(System.String,System.String,System.Int32,System.Boolean,Ingeniux.CMS.Enums.EnumPageSchemaType,System.String,System.String,Ingeniux.CMS.Presentation.IPagePresentationCollection,System.String)"]

viewName (Optional)
Type: SystemString

[Missing <param name="viewName"/> documentation for "M:Ingeniux.CMS.ISchemaManager.CreateSchema(System.String,System.String,System.Int32,System.Boolean,Ingeniux.CMS.Enums.EnumPageSchemaType,System.String,System.String,Ingeniux.CMS.Presentation.IPagePresentationCollection,System.String)"]

stylesheet (Optional)
Type: SystemString

[Missing <param name="stylesheet"/> documentation for "M:Ingeniux.CMS.ISchemaManager.CreateSchema(System.String,System.String,System.Int32,System.Boolean,Ingeniux.CMS.Enums.EnumPageSchemaType,System.String,System.String,Ingeniux.CMS.Presentation.IPagePresentationCollection,System.String)"]

presentations (Optional)
Type: Ingeniux.CMS.PresentationIPagePresentationCollection
Specifies the presentations collection that is applied to pages created from this schema.
thumbnailPath (Optional)
Type: SystemString

[Missing <param name="thumbnailPath"/> documentation for "M:Ingeniux.CMS.ISchemaManager.CreateSchema(System.String,System.String,System.Int32,System.Boolean,Ingeniux.CMS.Enums.EnumPageSchemaType,System.String,System.String,Ingeniux.CMS.Presentation.IPagePresentationCollection,System.String)"]

Return Value

Type: ISchema
The newly created schema.
Exceptions
ExceptionCondition
ArgumentNullExceptionWhen the "name" parameter is null, empty, or contains whitespace.
ArgumentExceptionWhen the "name" parameter is not a valid XML element name; there are already schemas with same root name or friendly name; or the view name or style sheet name is invalid.
Remarks

The schema returned is not yet saved to the content store.

The "name" paramter provided cannot be null, empty, or contain whitespace, and it must be a valid XML element name.

The friendly names and root element names are unique to the schema's collection. If any schemas with a matching friendly name or root element name already exist, an error is thrown.

The newly created schema will be in draft mode. It cannot be used to create pages until it is saved with a new version.

If the icon ID provided doesn't match any icon images, it defaults to a blank page icon.

The newly created schema doesn't have any fields yet. Fields must be added to the returned object before saving (for more information, see UserWriteSession disposal).

On a Dynamic Site Server (run-time) site, the rendering engine first searches for the view that matches either the value of ViewName, or the RootName of page document. If the view doesn't exist, it tries to fall back to the style sheet. isViewPage being true only means it is not needed to set the style sheet property; it doesn't mean you cannot set it.

Setting isViewPage to true doesn't mean that the ViewName property is required.

The purpose of this parameter is for visual presentation only in the CMS schema designer user interface.

Examples
The following example shows how to create a page schema, add one attribute and one element field, and save to allow page creation.
C#
using (IUserWriteSession session = _Store.OpenWriteSession(operatingUser))
{
        //Create a new View page with View Name "News", instead of the default "NewsDetails"
        schema = session.SchemasManager.CreateSchema("NewsDetails", "News Details", 2, False, True, "News");

        ISchemaFieldType attributeType = session.SchemasManager.FieldDefinitions.ItemByID("1");
        ISchemaField attribField = new SchemaField(attributeType,
            "Source", "Source Publication");
        attribField.HelpText = "The Publication that first published the news";
        attribField.DefaultValue = "Seattle Times";

        ISchemaFieldType textElementType = session.SchemasManager.FieldDefinitions.ItemByID("2");
        ISchemaField textField = new SchemaField(textElementType,
            "Title", "Title", true, false, false);

        schema.AddField(attribField);
        schema.AddField(textField);
        schema.Save(true);
}
See Also