To save time and make site administration easier for our Kentico customers, we often create a custom module to give them a custom control center.
We do that because Kentico is a very robust system. The official site touts 400+ web parts, and a quick glance at the two administrative portals reveals 13 admin tabs, most with many areas underneath them.
For a new user, getting up to speed with the content areas takes a bit of getting used to, and if you have a deeper site with custom tables or email templates they can quickly get lost trying to find those “once in a while” areas.
Step 1 – Create a custom module as a frameset
Creating a custom module is pretty easy and well covered at Kentico’s site here: http://devnet.kentico.com/docs/devguide/index.html?custom_modules.htm
So rather than go through those steps, I’m going to try to go over some useful tips for setting up the actual module. I recommend creating the module as a frameset so that you can add additional items easily:
A splash screen or introduction will provide a reminder of what each item can be used for in words that the client can easily understand and remember. To do this, create a basic frameset like so:
&lt;%@ Page Language=&quot;C#&quot; AutoEventWireup=&quot;true&quot; title=&quot;My Custom Module&quot; CodeFile=&quot;Default.aspx.cs&quot; Inherits=&quot;CustomModule.Default&quot; %&gt; &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Frameset//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd&quot;&gt; &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt; &lt;head runat=&quot;server&quot; enableviewstate=&quot;false&quot;&gt; &lt;title&gt;Custom Module Frameset&lt;/title&gt; &lt;/head&gt; &lt;frameset border=&quot;0&quot; rows=&quot;73, *&quot; id=&quot;rowsFrameset&quot;&gt; &lt;frame name=&quot;CustomModuleHeader&quot; src=&quot;Header.aspx&quot; frameborder=&quot;1&quot; scrolling=&quot;no&quot; noresize=&quot;noresize&quot; /&gt; &lt;frame name=&quot;CustomModuleContent&quot; src=&quot;splash.aspx&quot; frameborder=&quot;0&quot; /&gt; &lt;noframes&gt; &lt;body&gt; &lt;p&gt;This HTML frameset displays multiple Web pages. To view this frameset, use a Web browser that supports HTML 4.0 <!-- virus removed kpk -->and later. &lt;/p&gt; &lt;/body&gt; &lt;/noframes&gt; &lt;/frameset&gt; &lt;/html&gt;
Step 2 – Add some tabs to your modules navigation
Kentico has a nice tab header that can be used for this on the header.aspx page:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Header.aspx.cs" MasterPageFile="~/CMSMasterPages/UI/TabsHeader.master" Title="[Your Title Here]" Inherits="[Your Class Name]" Theme="Default"%>
To add tabs to the page use a string array as follows. Each page in the module should inherit from CMS.UIControls.CMSToolsPage The first index of the string array should be updated for the number of tabs, the second index maps to one of the properties below:
- 0 – Caption
- 1 – Onclick event (not usually
- 2 – URL of the link target
- 3 – Tooltip
- 4 to 11 – these are used for additional styling, which probably isn’t needed in most cases
string[,] tabs = new string[4, 4]; tabs[indx, 0] = "Latest Activity"; tabs[indx, 1] = ""; tabs[indx, 2] = "Splash.aspx" ; indx++; // Repeat above for all of your tabs // This sets the tabs in the master page to the array that set above this.CurrentMaster.Tabs.Tabs = tabs; // This must be the same as the name of your // content frame in the aspx code for frameset page. this.CurrentMaster.Tabs.UrlTarget = "CustomModuleContent";
The indx variable works well so you can reorder the tab sections easily. And remember that for that first array the string constructor is 1 based, but the accessor is zero based. So if you declare – new string [4,4] as above you can only create 4 tabs (which would be tabs[3, 0] ) . Also – a key thing to note is that the URL doesn’t need to be a custom module page. It can be any valid URL, recent site we launched leveraged a good deal of Kentico’s modules for custom tables, product data, and email templates. This meant the content editor had to traverse several different menu options in order to find what he needed. An easy solution for this was to create links to custom tabs as navigation items in the module. Another easy feature was to create a page with links to specific email templates from within the module. Doing this means not having to find the right menu item, and in the case of email templates, find the right template out of all the different site templates that are in place. Kentico users will notice that “email template” includes site template, global templates, and ecommerce receipts. So this saves, clicks, supports calls and frustration and lets the client get to the important job of tweaking messaging for his customers.
// Link to custom tables by just getting the link of the table. //For more complex deployments you will need to get the //customtableID using data classes or a setting. tabs[indx, 0] = &quot;Subscriptions&quot;; // NAME tabs[indx, 2] = &quot;/CMSModules/CustomTables/Tools/CustomTable_Data_List.aspx?customtableid=3457&quot;; tabs[indx, 3] = &quot;General Subscription Details.&quot;; // TITLE // You can also link to common admin tasks, like the user listing tabs[indx, 0] = &quot;User Details&quot;; // NAME tabs[indx, 2] = &quot;/CMSModules/Membership/Pages/Users/User_List.aspx?siteid=2&quot;; tabs[indx, 3] = &quot;View All User Details. Use 'Custom Fields' for details&quot;; //or the orders under the ecommerce module tabs[indx, 0] = &quot;Orders&quot;; // NAME tabs[indx, 2] = &quot;/CMSModules/Ecommerce/Pages/Tools/Orders/Order_List.aspx&quot;; // LINK tabs[indx, 3] = &quot;View order details <!-- virus removed kpk -->and process.&quot;; // TITLE
Example 2: Make it easier to audit content
One of the first implementations we used was for a general content review. Using the unigrid and a custom table (more on that in another post) we built this module to make it easier to find incomplete physician records. As fields and criteria were added, we were able to expand the filter with different targeted database queries to help them zero in on what needed to be updated. A simple CSV export made it easy to create contact sheets for follow up and deep links to the CMS made it quick to update the physicians record. The
With custom modules the possibilities are endless. Well, not really, but it is a very powerful tool. You can of course create modules to support custom development (that is, after all, one of the best reasons to use Kentico). but always be on the lookout for easy modifications that offer high reward. A few hours building custom modules is the the final piece to the puzzle that turns a satisfied client into a grateful and happy Kentico user.