Click or drag to resize

ISchemaManagerCreateComponentSchema Method


Creates a new component schema. This schema creates a component page, which doesn't have a fixed view associated with it.

Namespace:  Ingeniux.CMS
Assembly:  Ingeniux.CMS.CSAPI (in Ingeniux.CMS.CSAPI.dll) Version: 10.6.308
Syntax
ISchema CreateComponentSchema(
	string name,
	string friendlyName,
	int icon,
	string thumbnailPath = ""
)

Parameters

name
Type: SystemString
The new schema's root element name, which 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.
thumbnailPath (Optional)
Type: SystemString

[Missing <param name="thumbnailPath"/> documentation for "M:Ingeniux.CMS.ISchemaManager.CreateComponentSchema(System.String,System.String,System.Int32,System.String)"]

Return Value

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

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

The "name" parameter provided cannot be null, empty, or 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).

Examples
The following example shows how to create a component schema, add one attribute and one element field, and save to allow page creation.
C#
using (IUserWriteSession session = _Store.OpenWriteSession(operatingUser))
{
        schema = session.SchemasManager.CreateComponentSchema("NewsDetails", "News Details", 2);

        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