Sitefinity CMS
Search Sitefinity 3.x and older versions
Contents
Introduction
What is New in This Sitefinity Version
Readers Guidelines
Installation
Core Concepts
Sitefinity in Visual Studio
Sitefinity Building Parts
Developing with Sitefinity
Data Access
Pages
Controls
Modules
Adding New Modules to Sitefinity
Modules API
Modules API Overview
Generic Content
Overview of Generic Content API
Important Interfaces of Generic Content Module
Content Items
Content Item Overview
Content Items Overview
Creating Content Items
Finding Content Items
Modifying Content Items
Deleting Content Items
Comments
Categories
Tags
Generic Content Based Modules
Lists
Polls
Forums
Newsletters
Services
Programming Security
Personalization Framework
Designing with Sitefinity
Security
How-to
API Reference
PID463; RID7; VID0; IsStatic1
Creating Content Items
Send comments
on this topic.
See Also
Developing with Sitefinity > Modules > Modules API > Generic Content > Content Items > Creating Content Items
Glossary Item Box
There are three methods for creating a content item:
CreateContent(string mimeType)
-
Create content item with specified MIME type
CreateContent(string mimeType, Guid id)
-
Create content item with specified MIME type and ID of the content item
Create content item with specified MIME type:
CreateContent(string mimeType)
Copy Code
// create new instance of ContentManager
Telerik.Cms.Engine.ContentManager contentManager =
new
Telerik.Cms.Engine.ContentManager();
// create an empty content
Telerik.Cms.Engine.IContent newContent = contentManager.CreateContent(
"text/html"
);
// save the initial content properties
// note that properties such as ID are automatically
// set by Sitefinity. This however does not mean that you cannot
// change them
newContent.Content =
"My first content ... some text"
;
// set meta keys for the content item
newContent.SetMetaData(
"Name"
,
"Content Item 1 Name"
);
newContent.SetMetaData(
"Author"
,
"author name"
);
newContent.SetMetaData(
"Description"
,
"Some info about the content item."
);
//save the content
contentManager.SaveContent(newContent);
Create content item with specified MIME type and ID of the content item:
CreateContent(string mimeType, Guid id)
Copy Code
// create new instance of ContentManager
Telerik.Cms.Engine.ContentManager contentManager =
new
Telerik.Cms.Engine.ContentManager();
// just for demonstration - create Guid number
Guid contentID =
new
Guid(
"936DA01F-9ABD-4d9d-80C7-02AF85C822A8"
);
// create an empty content
Telerik.Cms.Engine.IContent newContent = contentManager.CreateContent(
"text/html"
, contentID);
// save the initial content properties
// note that properties such as ID are automatically
// set by Sitefinity. This however does not mean that you cannot
// change them
newContent.Content =
"My second content ... some text"
;
// set meta keys for the content item
newContent.SetMetaData(
"Name"
,
"Content Item 2 Name"
);
newContent.SetMetaData(
"Author"
,
"author name"
);
newContent.SetMetaData(
"Description"
,
"Some info about the content item."
);
//save the content
contentManager.SaveContent(newContent);
See Also
Overview of Generic Content API
Important Interfaces of Generic Content Module
Content Items Overview
Finding Content Items
Modifying Content Items
Deleting Content Items
Comments Overview
Creating Comments
Finding Comments
Modifying Comments
Deleting Comments
Managing Read Status of Comments
Categories Overview
Creating Categories
Finding Categories
Modifying Categories
Deleting Categories
Tags Overview
Creating Tags
Finding Tags
Modifying Tags
Deleting Tags
not -included