Contents
Core Concepts
Sitefinity in Visual Studio
Sitefinity Building Parts
Developing with Sitefinity
Designing with Sitefinity
Security
How-to
API Reference
| |
| Finding Content Items |
Send comments on this topic. |
| See Also |
|
Developing with Sitefinity > Modules > Modules API > Generic Content > Content Items > Finding Content Items |
There are several ways in which you can find one or more content items:
- GetContent() - Get all content for the current provider
- GetContent(Guid id) - Get content by specified ID
- GetContent(Guid id, string itemInfo) - Get content by specified ID and item
information
- GetContent(string sortExp) - Get the list of all generic content objects ordered by
passed sorting expression
- GetContent(int from, int max) - Get the list of all generic content objects for the
specified starting position and maximum number
- GetContent(int from, int max, string sortExp) – Get specific subset of content
with specified starting position and maximum number, ordered by sorting expression
- GetContent(int from, int max, string sortExp, Guid parentID) - Get
specific subset of content for the specified parent ID, with set starting position and maximum number, ordered by sorting expression
- GetContent(params IMetaSearchInfo[] filter) - Get filtered subset of content
- GetContent(string sortExp, params IMetaSearchInfo[] filter) - Get filtered and
ordered subset of content
- GetContent(int from, int max, params IMetaSearchInfo[] filter) - Get filtered
subset of content with specified starting position and maximum number
- GetContent(int from, int max, string sortExp, params IMetaSearchInfo[] filter)
- Get filtered subset of content with specified starting position and maximum number, ordered by sorting expression
- GetContent(int from, int max, string sortExp, ContentStatus status, params
IMetaSearchInfo[] filter) - Get filtered subset of content with specified starting position and maximum number, ordered by sorting expression, with
status of the content
- GetContent(int from, int max, string sortExp, ContentStatus? status,
Guid[] parentIDs, string filterExp) - Get subset of content with specified starting position and maximum number, ordered by sorting expression, filtered by
filtering expression, with status of the content, and specified parent IDs
- GetContent(int from, int max, string sortExp, ContentStatus? status,
Guid[] parentIDs, IMetaSearchInfo[] filter) - Get filtered subset of content with specified starting position and maximum number, ordered by sorting
expression, with status of the content, and specified parent IDs
- GetContent(int from, int max, string sortExp, ContentStatus?
status, string itemInfo, Guid[] parentIDs, IMetaSearchInfo[] filter) - Get filtered subset of content with specified starting position and maximum number,
ordered by sorting expression, with status of the content, item information, and specified parent IDs
- GetContent(int from, int max, string sortExp, Guid[] parentIDs) - Get
specific subset of content with specified starting position and maximum number, ordered by sorting expression, and specified parent IDs
- GetContent(int from, int max, IMetaSearchInfo[] filter, Guid[] parentIDs)
- Get filtered subset of content with specified starting position and maximum number, and specified parent IDs
- GetContent(int from, int max, string sortExp, ContentStatus status, Guid[]
parentIDs) - Get specific subset of content with specified starting position and maximum number, ordered by sorting expression, status of the
content, and specified parent IDs
- GetContent(int from, int max, string sortExp, string tagName) - Get
specific subset of content with specified starting position and maximum number, ordered by sorting expression, and tagged by specific tag
- GetContent(int from, int max, string sortExp, string tagName, Guid[]
parentIDs) - Get specific subset of content with specified starting position and maximum number, ordered by sorting expression, tagged by specific
tag, and specified parent IDs
- GetChildItems(Guid parentID) - Get all content items of a given parent
- GetChildItems(int max, int from, Guid parentID) - Get specified
subset of content items of a given parent
- GetFilter(string filterExp) - Get filter of type IMetaSearchInfo[]
from filter expression of type string
In the examples for the methods where there is parent or parent ID, Blogs module is used (which is currently the only implementation of the ParentID
propery of Generic Content based modules - blog is a parent of a post). Therefore, in order to demonstrate how to implement the methods where parent parameter is passed, the
BlogManager (the API class of Blogs module) is used.
 |
The Content property of the BlogManager class is the instance of ContentManager instantiated with a
proper provider for Blogs. While all Generic Content based modules (such as Blogs, Events, News, and so on) are using the ContentManager class
for most of their data-related work, it is necessary that ContentManager is instantiated through the respective module's
Content property and not directly through ContentManager's constructor.
|
Let’s examine the examples for each of the ways to find one or more content items:
Get all content for the current provider :
| GetContent() |
Copy Code |
|
// create new instance of ContentManager Telerik.Cms.Engine.ContentManager contentManager =
new Telerik.Cms.Engine.ContentManager(); // get all content
items IList listOfContentItems = contentManager.GetContent(); if (listOfContentItems.Count > 0)
{
foreach(Telerik.Cms.Engine.IContent contentItem in
listOfContentItems)
Response.Write(contentItem.Content + "<br />");
}
|
Get content by specified ID:
| GetContent(Guid id) |
Copy Code |
|
// create new instance of ContentManager Telerik.Cms.Engine.ContentManager contentManager =
new Telerik.Cms.Engine.ContentManager(); // get all content
items IList listOfContentItems = contentManager.GetContent(); if (listOfContentItems.Count > 0)
{
// get ID of the first content item. This is redundant step - just for demonstration
Guid firstContentId = ((Telerik.Cms.Engine.IContent)listOfContentItems[0]).ID;
// get the content item by passed ID
Telerik.Cms.Engine.IContent theContentItem = contentManager.GetContent(firstContentId);
Response.Write(theContentItem.Content + "<br />");
}
|
Get content by specified ID and item information:
| GetContent(Guid id, string itemInfo) |
Copy Code |
|
// create new instance of ContentManager Telerik.Cms.Engine.ContentManager contentManager =
new Telerik.Cms.Engine.ContentManager(); // create 2 new content items, set
content and ItemInfo properties and get IDs Telerik.Cms.Engine.IContent newContent1 =
contentManager.CreateContent("text/html");
newContent1.Content = "My fifth content";
newContent1.ItemInfo = "content item";
Guid newContent1Id = newContent1.ID;
contentManager.SaveContent(newContent1);
Telerik.Cms.Engine.IContent newContent2 = contentManager.CreateContent("text/html");
newContent2.Content = "My sixth content";
newContent2.ItemInfo = "content item";
Guid newContent2Id = newContent2.ID;
contentManager.SaveContent(newContent2); // set the ItemInfo value for which to get a content item string contentItemInfo = "content item"; // get content item that has the specified itemInfo value Telerik.Cms.Engine.IContent contentItem =
contentManager.GetContent(newContent1Id, contentItemInfo);
Response.Write(contentItem.Content + "<br />" + " This content
has the following ItemInfo value: " + contentItem.ItemInfo + "<br />");
|
Get the list of all generic content objects ordered by passed sorting expression:
This examples includes creating two new content items that have specifically set meta keys.
 |
The sorting expression sorts only meta keys! The possible key values could be found in the web.config
file, in the <metaFields> section, for the given module. For example, for Generic Content, the key starts with Generic_Content (such as
Generic_Content.Author for the Author meta field). Thus, a key that could be passed as parameter is "Author", while a possible value is
"John". |
| GetContent(string sortExp) |
Copy Code |
|
// create new instance of ForumManager 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 newContent.Content = "My seventh content"; // save values
for the meta keys newContent.SetMetaData("Name",
"My First Job");
newContent.SetMetaData("Author", "author of 7th
content");
newContent.SetMetaData("Description", "Some info about the content
item."); //save the content contentManager.SaveContent(newContent); // create an empty content Telerik.Cms.Engine.IContent newContent2 = contentManager.CreateContent("text/html"); // save the initial content properties newContent2.Content = "My eighth content"; // save values for the meta keys newContent2.SetMetaData("Name", "My
Friends");
newContent2.SetMetaData("Author", "author of 8th
content");
newContent2.SetMetaData("Description", "Some info about the content
item."); //save the content contentManager.SaveContent(newContent2); // get all content in descending order IList listOfContentItems = contentManager.GetContent("Name DESC"); if (listOfContentItems.Count > 0)
{
foreach (Telerik.Cms.Engine.IContent contentItem in
listOfContentItems)
Response.Write(contentItem.GetMetaData("Name") +
"<br />");
}
|
Get the list of all generic content objects for the specified starting position and maximum number:
| GetContent(int from, int max) |
Copy Code |
|
// create new instance of ContentManager Telerik.Cms.Engine.ContentManager contentManager =
new Telerik.Cms.Engine.ContentManager(); // get content items - start from
the first one ('0'), and get two items ('2') IList listOfContentItems = contentManager.GetContent(0,
2); if (listOfContentItems.Count > 0)
{
foreach (Telerik.Cms.Engine.IContent contentItem in
listOfContentItems)
Response.Write(contentItem.Content + "<br />");
}
|
Get specific subset of content with specified starting position and maximum number, ordered by sorting expression:
| GetContent(int from, int max, string sortExp) |
Copy Code |
|
// create new instance of ContentManager Telerik.Cms.Engine.ContentManager contentManager =
new Telerik.Cms.Engine.ContentManager(); // get content items in ascending
order for Name meta key - start from the first one ('0'), and get four items ('4') IList listOfContentItems =
contentManager.GetContent(0, 4, "Name ASC"); if (listOfContentItems.Count > 0)
{
foreach (Telerik.Cms.Engine.IContent contentItem in
listOfContentItems)
Response.Write(contentItem.GetMetaData("Name") +
"<br />");
}
|
Get specific subset of content for the specified parent ID, with set starting position and maximum number, ordered by
sorting expression:
| GetContent(int from, int max, string sortExp, Guid parentID) |
Copy Code |
|
// create new instance of BlogManager Telerik.Blogs.BlogManager blogManager = new Telerik.Blogs.BlogManager(); // get all blogs IList
listOfAllBlogs = blogManager.GetBlogs(); // get second blog item Telerik.Blogs.IBlog
secondBlog = blogManager.GetBlog(((Telerik.Blogs.IBlog)listOfAllBlogs[1]).ID);
Response.Write("Name of first blog is " + secondBlog.Name + "<br
/>"); // get content items in ascending order for Name meta key,
// start from the first one ('0'), and get four items ('4')
// where the parent is the blog secondBlog IList listOfContentItems = blogManager.Content.GetContent(0, 0,
"Name ASC", secondBlog.ID); if (listOfContentItems.Count > 0)
{
foreach (Telerik.Cms.Engine.IContent contentItem in
listOfContentItems)
Response.Write("Content is " + contentItem.Content
+ "<br />");
}
|
Get filtered subset of content:
For more information about the filter, see the description of the IMetaSearchInfo Interface.
 |
When creating the filter, notice that the full name of the content item is added as a value ("Name_of_Content_Item"). This is necessary to get any
result sine the default search condition is Equal, which means that unless the value is the same it will not be returned. To overcome that, add a
Like search condition. The following filter will pick all short text items that contain the word "Name" in their Name meta key field:
filter.Add(new Telerik.Cms.Engine.MetaSearchInfo(Telerik.Cms.Engine.MetaValueTypes.ShortText, "Name",
"Name",Telerik.Cms.Engine.SearchCondition.Like));
|
| GetContent(params IMetaSearchInfo[] filter) |
Copy Code |
|
// create new instance of ContentManager Telerik.Cms.Engine.ContentManager contentManager =
new Telerik.Cms.Engine.ContentManager(); // create list that contains
filters List<Telerik.Cms.Engine.IMetaSearchInfo> filter = new List<Telerik.Cms.Engine.IMetaSearchInfo>(); // add a new filter to the list filter.Add(new Telerik.Cms.Engine.MetaSearchInfo(Telerik.Cms.Engine.MetaValueTypes.ShortText, "Name", "Name_of_Content_Item")); // get content items filtered
by specified filters IList listOfContentItems = contentManager.GetContent(filter.ToArray()); if (listOfContentItems.Count > 0)
{
foreach (Telerik.Cms.Engine.IContent contentItem in
listOfContentItems)
Response.Write("<br />" +
contentItem.GetMetaData("Name") + "<br />");
}
|
Get filtered and ordered subset of content:
| GetContent(string sortExp, params IMetaSearchInfo[] filter) |
Copy Code |
|
// create new instance of ContentManager Telerik.Cms.Engine.ContentManager contentManager =
new Telerik.Cms.Engine.ContentManager(); // create list that contains
filters List<Telerik.Cms.Engine.IMetaSearchInfo> filter = new List<Telerik.Cms.Engine.IMetaSearchInfo>(); // add a new filter to the list filter.Add(new Telerik.Cms.Engine.MetaSearchInfo(Telerik.Cms.Engine.MetaValueTypes.ShortText, "Name", "Name",Telerik.Cms.Engine.SearchCondition.Like)); // get
content items filtered by specified filters and ordered descendingly IList listOfContentItems =
contentManager.GetContent("Name DESC",filter.ToArray()); if
(listOfContentItems.Count > 0)
{
foreach (Telerik.Cms.Engine.IContent contentItem in
listOfContentItems)
Response.Write("<br />" +
contentItem.GetMetaData("Name") + "<br />");
}
|
Get filtered subset of content with specified starting position and maximum number:
| GetContent(int from, int max, params IMetaSearchInfo[] filter) |
Copy Code |
|
// create new instance of ContentManager Telerik.Cms.Engine.ContentManager contentManager =
new Telerik.Cms.Engine.ContentManager(); // create list that contains
filters List<Telerik.Cms.Engine.IMetaSearchInfo> filter = new List<Telerik.Cms.Engine.IMetaSearchInfo>(); // add a new filter to the list filter.Add(new Telerik.Cms.Engine.MetaSearchInfo(Telerik.Cms.Engine.MetaValueTypes.ShortText, "Name", "Name", Telerik.Cms.Engine.SearchCondition.Like)); // get
content items filtered by specified filters, starting from the first one ('0'), and getting two items ('2') IList
listOfContentItems = contentManager.GetContent(0,2, filter.ToArray()); if (listOfContentItems.Count > 0)
{
foreach (Telerik.Cms.Engine.IContent contentItem in
listOfContentItems)
Response.Write("<br />" +
contentItem.GetMetaData("Name") + "<br />");
}
|
Get filtered subset of content with specified starting position and maximum number, ordered by sorting expression:
| GetContent(int from, int max, string sortExp, params IMetaSearchInfo[] filter) |
Copy Code |
|
// create new instance of ContentManager Telerik.Cms.Engine.ContentManager contentManager =
new Telerik.Cms.Engine.ContentManager(); // create list that contains
filters List<Telerik.Cms.Engine.IMetaSearchInfo> filter = new List<Telerik.Cms.Engine.IMetaSearchInfo>(); // add a new filter to the list filter.Add(new Telerik.Cms.Engine.MetaSearchInfo(Telerik.Cms.Engine.MetaValueTypes.ShortText, "Name", "Name", Telerik.Cms.Engine.SearchCondition.Like)); // get
content items filtered by specified filters, sorted, starting from the first one ('0'), and getting three items ('3') IList
listOfContentItems = contentManager.GetContent(0, 3, "Name ASC",
filter.ToArray()); if (listOfContentItems.Count > 0)
{
foreach (Telerik.Cms.Engine.IContent contentItem in
listOfContentItems)
Response.Write("<br />" +
contentItem.GetMetaData("Name") + "<br />");
}
|
Get filtered subset of content with specified starting position and maximum number, ordered by sorting
expression, with status of the content:
| GetContent(int from, int max, string sortExp, ContentStatus status, params IMetaSearchInfo[] filter) |
Copy Code |
|
// create new instance of ContentManager Telerik.Cms.Engine.ContentManager contentManager =
new Telerik.Cms.Engine.ContentManager(); // create list that contains
filters List<Telerik.Cms.Engine.IMetaSearchInfo> filter = new List<Telerik.Cms.Engine.IMetaSearchInfo>(); // add a new filter to the list filter.Add(new Telerik.Cms.Engine.MetaSearchInfo(Telerik.Cms.Engine.MetaValueTypes.ShortText, "Name", "Name", Telerik.Cms.Engine.SearchCondition.Like)); // get
content items filtered by specified filters, sorted,
// starting from the first one ('0'), and getting three items ('3')
// with content status - Published IList listOfContentItems = contentManager.GetContent(0, 3, "Name ASC",Telerik.Cms.Engine.ContentStatus.Published, filter.ToArray()); if
(listOfContentItems.Count > 0)
{
foreach (Telerik.Cms.Engine.IContent contentItem in
listOfContentItems)
Response.Write("<br />" +
contentItem.GetMetaData("Name") + "<br />");
}
|
Get subset of content with specified starting position and maximum number, ordered by sorting
expression, filtered by filtering expression, with status of the content, and specified parent IDs
| GetContent(int from, int max, string sortExp, ContentStatus? status, Guid[] parentIDs, string filterExp) |
Copy Code |
|
// create new instance of BlogManager Telerik.Blogs.BlogManager blogManager = new Telerik.Blogs.BlogManager(); // get all blogs IList
listOfAllBlogs = blogManager.GetBlogs(); // create an array of blog IDs and populate it Guid[] parentIDArray = new Guid[5];
parentIDArray[0] =
((Telerik.Blogs.IBlog)listOfAllBlogs[0]).ID;
parentIDArray[1] =
((Telerik.Blogs.IBlog)listOfAllBlogs[1]).ID;
parentIDArray[2] =
((Telerik.Blogs.IBlog)listOfAllBlogs[2]).ID; // get content items in ascending order for Name meta key,
// start from the first one ('0'), and get three items ('3')
// where the parent is the blog secondBlog
// and filter the items by title where it contains the word 'post' IList listOfContentItems =
blogManager.Content.GetContent(0, 3, "Title ASC", null, parentIDArray, "Title~'post';"); if (listOfContentItems.Count > 0)
{
foreach (Telerik.Cms.Engine.IContent contentItem in
listOfContentItems)
Response.Write("Content is " + contentItem.Content
+ "<br />");
}
|
Get filtered subset of content with specified starting position and maximum number, ordered by sorting
expression, with status of the content, and specified parent IDs:
The ContentStatus parameter could be used only when Workflow is turned on. If not, use null instead.
| GetContent(int from, int max, string sortExp, ContentStatus? status, Guid[] parentIDs, IMetaSearchInfo[] filter) |
Copy Code |
|
// create new instance of BlogManager Telerik.Blogs.BlogManager blogManager = new Telerik.Blogs.BlogManager(); // get all blogs IList
listOfAllBlogs = blogManager.GetBlogs(); // create an array of blog IDs and populate it Guid[] parentIDArray = new Guid[5];
parentIDArray[0] =
((Telerik.Blogs.IBlog)listOfAllBlogs[0]).ID;
parentIDArray[1] =
((Telerik.Blogs.IBlog)listOfAllBlogs[1]).ID; // use the GetFilter method to create a filter array from a filter expression
string Telerik.Cms.Engine.IMetaSearchInfo[] filter =
blogManager.Content.GetFilter("Title~'post';");
// get content items in ascending order for Title meta key,
// get all items ('0,0'), filter the items,
// where the parent IDs are passed in an array IList listOfContentItems = blogManager.Content.GetContent(0, 0,
"Title ASC", null, parentIDArray,
filter.ToArray()); if (listOfContentItems.Count > 0)
{
foreach (Telerik.Cms.Engine.IContent contentItem in
listOfContentItems)
Response.Write("Content is " + contentItem.Content
+ "<br />");
}
|
Get filtered subset of content with specified starting position and maximum number, ordered by
sorting expression, with status of the content, item information, and specified parent IDs:
Have in mind that the default search condition when creating a new filter is And. Do not forget to specify the search condition if the filter should use
any operator different from And.
As shown in the previous example, another way of creating a filter of type IMetaSearchInfo[] is to use the GetFilter method provided by
the ContentManager.
The ContentStatus parameter could be used only when Workflow is turned on. If not, use null instead.
| GetContent(int from, int max, string sortExp, ContentStatus? status, string itemInfo, Guid[] parentIDs, IMetaSearchInfo[] filter) |
Copy Code |
|
// create new instance of BlogManager Telerik.Blogs.BlogManager blogManager = new Telerik.Blogs.BlogManager(); // get all blogs IList
listOfAllBlogs = blogManager.GetBlogs(); // get all blogs IList listOfAllBlogs =
blogManager.GetBlogs(); // create an array of blog IDs and populate it parentIDArray[0] =
((Telerik.Blogs.IBlog)listOfAllBlogs[0]).ID;
parentIDArray[1] =
((Telerik.Blogs.IBlog)listOfAllBlogs[1]).ID; // create a list of filters List<Telerik.Cms.Engine.IMetaSearchInfo> filter = new List<Telerik.Cms.Engine.IMetaSearchInfo>(); // add a new filter to the list filter.Add(new Telerik.Cms.Engine.MetaSearchInfo(Telerik.Cms.Engine.MetaValueTypes.ShortText, "Title", "post", Telerik.Cms.Engine.SearchCondition.Like)); // get
content items in ascending order for Title meta key,
// get all items ('0,0'), filter the items,
// where the parent IDs are passed in an array IList listOfContentItems = blogManager.Content.GetContent(0, 0,
"Title ASC", null, "
", parentIDArray, filter.ToArray()); if (listOfContentItems.Count >
0)
{
foreach (Telerik.Cms.Engine.IContent contentItem in
listOfContentItems)
Response.Write("Content is " + contentItem.Content
+ "<br />");
}
|
Get specific subset of content with specified starting position and maximum number, ordered by sorting
expression, and specified parent IDs:
| GetContent(int from, int max, string sortExp, Guid[] parentIDs) |
Copy Code |
|
// create new instance of BlogManager Telerik.Blogs.BlogManager blogManager = new Telerik.Blogs.BlogManager(); // get all blogs IList
listOfAllBlogs = blogManager.GetBlogs(); // create an array of blog IDs and populate it Guid[] parentIDArray = new Guid[5];
parentIDArray[0] =
((Telerik.Blogs.IBlog)listOfAllBlogs[0]).ID;
parentIDArray[1] =
((Telerik.Blogs.IBlog)listOfAllBlogs[1]).ID; // get content items in ascending order for Title meta key,
// get all items ('0,0'),
// where the parent IDs are passed in an array IList listOfContentItems = blogManager.Content.GetContent(0, 0,
"Title ASC", parentIDArray); if (listOfContentItems.Count > 0)
{
foreach (Telerik.Cms.Engine.IContent contentItem in
listOfContentItems)
Response.Write("Content is " + contentItem.Content
+ "<br />");
}
|
Get filtered subset of content with specified starting position and maximum number, and specified parent
IDs:
| GetContent(int from, int max, IMetaSearchInfo[] filter, Guid[] parentIDs) |
Copy Code |
|
// create new instance of BlogManager Telerik.Blogs.BlogManager blogManager = new Telerik.Blogs.BlogManager(); // get all blogs IList
listOfAllBlogs = blogManager.GetBlogs(); // create an array of blog IDs and populate it Guid[] parentIDArray = new Guid[5];
parentIDArray[0] =
((Telerik.Blogs.IBlog)listOfAllBlogs[0]).ID;
parentIDArray[1] =
((Telerik.Blogs.IBlog)listOfAllBlogs[1]).ID; // create a list of filters List<Telerik.Cms.Engine.IMetaSearchInfo> filter = new List<Telerik.Cms.Engine.IMetaSearchInfo>(); // add a new filter to the list filter.Add(new Telerik.Cms.Engine.MetaSearchInfo(Telerik.Cms.Engine.MetaValueTypes.ShortText, "Title", "post", Telerik.Cms.Engine.SearchCondition.Like)); // get
all content items ('0,0')
// filter the items,
// where the parent IDs are passed in an array IList listOfContentItems = blogManager.Content.GetContent(0, 0,
filter.ToArray(), parentIDArray); if (listOfContentItems.Count > 0)
{
foreach (Telerik.Cms.Engine.IContent contentItem in
listOfContentItems)
Response.Write("Content is " + contentItem.Content
+ "<br />");
}
|
Get specific subset of content with specified starting position and maximum number, ordered by sorting
expression, status of the content, and specified parent IDs:
The ContentStatus parameter could be used only when Workflow is turned on. If not, use null instead.
| GetContent(int from, int max, string sortExp, ContentStatus status, Guid[] parentIDs) |
Copy Code |
|
// create new instance of BlogManager Telerik.Blogs.BlogManager blogManager = new Telerik.Blogs.BlogManager(); // get all blogs IList
listOfAllBlogs = blogManager.GetBlogs(); // create an array of blog IDs and populate it Guid[] parentIDArray = new Guid[5];
parentIDArray[0] =
((Telerik.Blogs.IBlog)listOfAllBlogs[0]).ID;
parentIDArray[1] =
((Telerik.Blogs.IBlog)listOfAllBlogs[1]).ID; // get content items in ascending order for Title meta key,
// get all items ('0,0'),
// take only Published ones (WORKFLOW must be ON)
// where the parent IDs are passed in an array IList listOfContentItems = blogManager.Content.GetContent(0, 0,
"Title ASC",Telerik.Cms.Engine.ContentStatus.Published, parentIDArray); if (listOfContentItems.Count > 0)
{
foreach (Telerik.Cms.Engine.IContent contentItem in
listOfContentItems)
Response.Write("Content is " + contentItem.Content
+ "<br />");
}
|
Get specific subset of content with specified starting position and maximum number, ordered by sorting expression, and
tagged by specific tag:
| GetContent(int from, int max, string sortExp, string tagName) |
Copy Code |
|
// create new instance of ContentManager Telerik.Cms.Engine.ContentManager contentManager =
new Telerik.Cms.Engine.ContentManager(); // get content items in ascending
order for Name meta key, all items ('0,0')
// tagged with the specified Tag IList listOfContentItems = contentManager.GetContent(0, 0, "Name ASC", "Tag 1"); if
(listOfContentItems.Count > 0)
{
foreach (Telerik.Cms.Engine.IContent contentItem in
listOfContentItems)
Response.Write(contentItem.GetMetaData("Name") +
"<br />");
}
|
Get specific subset of content with specified starting position and maximum number, ordered by sorting
expression, tagged by specific tag, and specified parent IDs:
| GetContent(int from, int max, string sortExp, string tagName, Guid[] parentIDs) |
Copy Code |
|
// create new instance of BlogManager Telerik.Blogs.BlogManager blogManager = new Telerik.Blogs.BlogManager(); // get all blogs IList
listOfAllBlogs = blogManager.GetBlogs(); // create an array of blog IDs and populate it Guid[] parentIDArray = new Guid[5];
parentIDArray[0] =
((Telerik.Blogs.IBlog)listOfAllBlogs[0]).ID;
parentIDArray[1] =
((Telerik.Blogs.IBlog)listOfAllBlogs[1]).ID; // get content items in ascending order for Title meta key,
// get all items ('0,0'),
// tagged with the specified Tag
// where the parent IDs are passed in an array IList listOfContentItems = blogManager.Content.GetContent(0, 0,
"Title ASC", "My tag",
parentIDArray); if (listOfContentItems.Count > 0)
{
foreach (Telerik.Cms.Engine.IContent contentItem in
listOfContentItems)
Response.Write("Content is " + contentItem.Content
+ "<br />");
}
|
Get all content items of a given parent:
| GetChildItems(Guid parentID) |
Copy Code |
|
// create new instance of BlogManager Telerik.Blogs.BlogManager blogManager = new Telerik.Blogs.BlogManager(); // get all blogs IList
listOfAllBlogs = blogManager.GetBlogs(); // get second blog item Telerik.Blogs.IBlog
firstBlog = blogManager.GetBlog(((Telerik.Blogs.IBlog)listOfAllBlogs[0]).ID); // get all content items where the parent is
the blog firstBlog IList listOfContentItems = blogManager.Content.GetChildItems(firstBlog.ID); if (listOfContentItems.Count > 0)
{
foreach (Telerik.Cms.Engine.IContent contentItem in
listOfContentItems)
Response.Write("Content is " + contentItem.Content
+ "<br />");
}
|
Get specified subset of content items of a given parent:
| GetChildItems(int max, int from, Guid parentID) |
Copy Code |
|
// create new instance of BlogManager Telerik.Blogs.BlogManager blogManager = new Telerik.Blogs.BlogManager(); // get all blogs IList
listOfAllBlogs = blogManager.GetBlogs(); // get second blog item Telerik.Blogs.IBlog
firstBlog = blogManager.GetBlog(((Telerik.Blogs.IBlog)listOfAllBlogs[0]).ID); // get the first two content items ('0,2')
where the parent is the blog firstBlog IList listOfContentItems = blogManager.Content.GetChildItems(0, 2,
firstBlog.ID); if (listOfContentItems.Count > 0)
{
foreach (Telerik.Cms.Engine.IContent contentItem in
listOfContentItems)
Response.Write("Content is " + contentItem.Content
+ "<br />");
}
|
Get filter of type IMetaSearchInfo[] from filter expression of type string:
| GetFilter(string filterExp) |
Copy Code |
|
// create new instance of ForumManager Telerik.Cms.Engine.ContentManager contentManager =
new Telerik.Cms.Engine.ContentManager(); // create a filter of type
IMetaSearchInfo[] from a filter expression of type string Telerik.Cms.Engine.IMetaSearchInfo[] filter = contentManager.GetFilter("Name~'post';");
|
See Also
|