You can query a content block by its ID. To search for a content blocks based on other property or criteria, see For developers: Find content blocks.
NOTE: The code examples below work with the ID of the master version of the content block. The examples return the master version. For more information about querying by the ID of the live version and returning the live version, see For developers: Query master and live versions.
To query a content block you can use the Native API or the Fluent API:
To query a specific content block using the Native API, you use the ContentManager class.
The following code queries the content block by its ID:
You use the GetContent method and filter based on the Id property. If the content block does not exist, the method returns null.
To find the content block, you can also use the GetContent method passing contentItemId, in the following way:
ContentItem contentItem = manager.GetContent(contentItemId);
To query a content block using the Fluent API, you use the content block facade. The following code queries the content block by its ID:
You first initialize the plural content block facade using App.WorkWith().ContentItems(). Then, you filter the content blocks based on the Id property. Finally, you use the Get method to get the content block. If the content block does not exist, the method returns null.
To find the content block, you can also use the singular content block facade, in the following way:
ContentItem contentItem = App.WorkWith().ContentItem(contentItemId).Get();
If there is no content block with the specified Id, the call to ContentItem(contentItemId) throws an exception of type ItemNotFoundException.
Back To Top
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important
Copyright © 2020 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.
Progress, Telerik, Ipswitch, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.
Powered by Progress Sitefinity