Using the Kentico CMS API
Thom Robbins (thomasr@kentico.com
Bryan Soltis (bryan@bitwizards.com)
Agenda
• Overview (Architecture/Objects) (Thom)
• CMS Context (Bryan)
• Document Management (Thom)
• Global Events (Thom)
...
Looking at Kentico CMS
Logical three tier architecture…
Architecture breakdown
Data layer
(+metadata)
Business layer
Controls libraries
UI components
Web project pages Live site ...
OO Basics - Object Creation Examples
// Create UserInfo
CMS.SiteProvider.UserInfo user = new CMS.SiteProvider.UserInfo();
...
API Everywhere!
• Class View is your Friend
CMS.SettingsProvider
.SettingsHelper
.SQLHelperClass
.TranslationHelp
er
CMS.G...
Helpers and general libraries
SettingsProvider
(metadata helpers)
SettingsHelper
(web.config)
SettingsKeyHelper
(web site ...
CMS Context
• CMS.CMSHelper.CMSContext class provides static
methods to access common information
Method
CurrentAliasPath
...
Document Management – How documents are stored
• Documents stored in SQL joined tables
– CMS_Tree – Table with basic docum...
Document Management – Versioning Internals
• Document versions and its history are stored in separate
tables
– CMS_Version...
Document Management Techniques
CMS.TreeEngine.TreeNode
• Not aware of
versioning/workflow/attachments
• Only works with pu...
Global Events
• Provide a way to execute custom events within the CMS
system
• Managed as a separate projects
• Web Config...
Global Event Classes
• The events are applied to all data items that are stored to the database. It
includes documents, us...
Modules
• Extend the CMS system to include your custom code
Additional Information
• Best samples are in your project!
• Get your poster
• Documentation -
http://devnet.kentico.com/D...
Upcoming SlideShare
Loading in …5
×

Using the Kentico CMS API

3,513 views

Published on

What can you do with the Kentico API? With over 200 ready to use web parts and a detailed API at your disposal the possibilities are endless. Event handlers, custom providers, customized data structures; programmatically create documents – to name a few. In this session we will explore ways that you can use this API to extend your CMS applications.

The co-speaker for this session is Bryan Soltis, Senior Software Engineer from Bit-Wizards Custom Software Solutions, Inc.

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,513
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
46
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • Standard 3-tier architecture

    Data driven object model (bussiness layer objects content based on metadata)

    UI consists of server controls, user controls and pages

    Modules are logically separated
  • We have helpers for almost everything

    If you plan to write any general code that can be used later by someone else:

    Locate the helper

    If the helper contains the method, use it

    If the helper contains similar method, enhance it by overriding it and provide original method so that the behavior of existing calls stays the same

    If the helper doesn’t contain the method, implement it in the helper
  • Using the Kentico CMS API

    1. 1. Using the Kentico CMS API Thom Robbins (thomasr@kentico.com Bryan Soltis (bryan@bitwizards.com)
    2. 2. Agenda • Overview (Architecture/Objects) (Thom) • CMS Context (Bryan) • Document Management (Thom) • Global Events (Thom) • Modules (Bryan)
    3. 3. Looking at Kentico CMS Logical three tier architecture…
    4. 4. Architecture breakdown Data layer (+metadata) Business layer Controls libraries UI components Web project pages Live site pages + admin UI pages Web parts + User controls CMSControls Helpers SettingsProvider Enumerations Infos & Providers Data engine GeneralConnection Abstract info Metadata infos (Class, Query, SettingsKey) Interfaces Third party code Module web parts + Module user controls Module controls Module Infos & Providers Module definitions Presentationlayer Best Practice Tip • Kentico CMS web site project provides examples of all sorts of code!
    5. 5. OO Basics - Object Creation Examples // Create UserInfo CMS.SiteProvider.UserInfo user = new CMS.SiteProvider.UserInfo(); // Set properties user.UserName = "Alice"; user.FirstName = "Alice"; user.LastName = "Cooper"; user.FullName = "Alice Cooper"; user.Email = "alice.cooper@domain.com"; user.IsEditor = true; user.IsGlobalAdministrator = true; user.PreferredCultureCode = "en-us"; user.Enabled = true; // Create new user CMS.SiteProvider.UserInfoProvider.SetUserInfo(user); // Prepare the TreeProvider (it must be initialized with user information when editing document structure) UserInfo ui = UserInfoProvider.GetUserInfo("administrator"); CMS.TreeEngine.TreeProvider tree = new CMS.TreeEngine.TreeProvider(ui); // Get the document (current culture) CMS.TreeEngine.TreeNode node = tree.SelectSingleNode(CMS.CMSHelper.CMSContext.CurrentSiteName, "/News/TestingWorkflow", CMS.CMSHelper.CMSContext.CurrentUser.PreferredCultureCode, false, null, false); if (node != null) { // Always delete the document with DocumentHelper, it handles all the dependencies CMS.WorkflowEngine.DocumentHelper.DeleteDocument(node, tree, true, true,true); } Example - Creating new user Example – Delete Document
    6. 6. API Everywhere! • Class View is your Friend CMS.SettingsProvider .SettingsHelper .SQLHelperClass .TranslationHelp er CMS.GlobalHelper .DataHelper .ContextHelper .AJAXHelper Library Specific CMS.Controls.CM SControlsHelper CMS.WorkflowEn gine.DocumentHe lper CMS.Blogs.BlogHe lper Some Examples… Best practice Tip: Class view is customizable to allow personalized organization and viewing
    7. 7. Helpers and general libraries SettingsProvider (metadata helpers) SettingsHelper (web.config) SettingsKeyHelper (web site settings) SqlHelperClass (low level DB connection, used only from SettingsProvider) DataHelper (basic data manipulation) TranslationHelper (conversion of IDs based on code names or GUIDs) GlobalHelper (general helpers) /Context (HTTP context related data) /Data (advanced data manipulation and validation) /Globalization (resource strings and cultures) /Markup (macros, HTML, XML, text, script) /Media (images and media manipulation and information) Library specific (module helpers) ControlsHelper CMSControlsHelper DocumentHelper WebFarmSyncHelperClass Etc. App_Code (helper functions) Functions.cs InstallerFunctions.cs BlogFunctions.cs EcommerceFunctions.cs Etc. Best Practice Tip • For general code locate the appropriate helper and use it • If the helper contains similar methods override and extend • Implement new behavior in helpers
    8. 8. CMS Context • CMS.CMSHelper.CMSContext class provides static methods to access common information Method CurrentAliasPath CurrentDocument CurrentPageInfo CurrentSite CurrentSiteName CurrentUser ViewMode ResolveCurrentPath Need a code snippet?
    9. 9. Document Management – How documents are stored • Documents stored in SQL joined tables – CMS_Tree – Table with basic document data shared between different language versions. Contains one record for all culture version of the document – CMS_Document – Table with document data of specified language version of the document. Contains one record representing one language version of the document – Coupled table – table that contains custom document type fields CMS_Tree CMS_Document Coupled table CMS_Document Coupled table CMS_Document Coupled table Best Practice Tip: Every document is stored in up to three (3) tables. Use the API to access documents
    10. 10. Document Management – Versioning Internals • Document versions and its history are stored in separate tables – CMS_VersionHistory – Table containing the document versions. Each version of the document is represented by one record that contains the complete document data in XML. – CMS_AttachmentHistory – Table containing the attachment version records. Each attachment version is bound to one or more document versions. Every record contains binary data of the attachment. – CMS_VersionAttachment – Table containing the bindings of the attachment versions to the document versions. CMS_VersionHistory CMS_VersionAttachment CMS_AttachmentHistory Version of attachments CMS_VersionAttachment CMS_AttachmentHistory Version of attachments
    11. 11. Document Management Techniques CMS.TreeEngine.TreeNode • Not aware of versioning/workflow/attachments • Only works with published records CMS.WorkflowEngine.DocumentHelper • Versioning/workflow/attachment aware • Use for all document deletes Best Practice Tip: CMS.WorkflowEngine.DocumentHelper is recommended to access document information CMS.CMSHelper.TreeHelper allows access to documents directly Best Practice Tip: TreeHelper.GetDocuments checks the view mode and then calls either TreeProvider or DocumentHelper
    12. 12. Global Events • Provide a way to execute custom events within the CMS system • Managed as a separate projects • Web Config Key Best Practice Tip: Developer documentation contains step by step instructions for implementing Global Events
    13. 13. Global Event Classes • The events are applied to all data items that are stored to the database. It includes documents, user information or any other settings • Receives DataClass CustomDataHandler.cs • Event applied to all exceptions that occur • Receives System.exception CustomExceptionHandler.cs • Allows the integration of external databases and modify the authentication and authorization processCustomSecurityHandler.cs • Execute custom actions when a document is created, updated or deletedCustomTreeNodeHandler.cs • Event applied to workflow documents (same as CustomTreeNodeHandler) • Same as CustomtreeNodeHandler CustomWorkflowHandler.cs Best Practice Tip: For Document events always use either the CustomTreeNodeHandler (no workflow) or CustomWorkFlowHandler (workflow) not the CustomDataHandler
    14. 14. Modules • Extend the CMS system to include your custom code
    15. 15. Additional Information • Best samples are in your project! • Get your poster • Documentation - http://devnet.kentico.com/Documentation.aspx • Code Snippet Library - http://devnet.kentico.com/Blogs/Thomas-Robbins.aspx • Marketplace - http://devnet.kentico.com/Marketplace.aspx

    ×