Client Pay Portal
 kentico

Adding Custom Functionality to a Kentico CMS Module in V8

Kentico CMS provides a ton of great features out of the box that accommodate many needs of projects. There are some times, however, that developers need to extend these features to fill a particular business need. While Kentico has always been extendable, adding this custom functionality hasn’t always been a simple process.

Take for example you need to extend the User’s module to allow the management of some custom attributes. In the past, the User’s module was a fairly static set of pages and controls created by Kentico. A good pattern would be to add a new interface with all of your custom functionality in one spot so the user knows exactly where to go. The User module consisted of several ASPX pages with various controls and unigrids. The main page had a static top navigation that while it is extendable, you had to either make a copy of it and add your code, or modify Kentico code (Bad!).


Version 7

Here’s what this would be like in v7:

This is the standard Users module in v7 with the top tabs.
 


If you wanted to add a new column, you had to do a few things.


1. Create a new page in the site (like above)

 

2. Edit the Users_Edit.aspx file to add your new tab to the layout.

 
 

3. Go look at your new, kind of awesome tab and functionality.

 

While this process is totally doable, modifying Kentico code is never a good thing. Assuming you wanted an integrated solution with the Users Module, you would have to create an entirely new module and replicate all of the User module code. Also not a fun thing to do. Most of the time, developers would just make a standalone module to accomplish this and provide the functionality through there.


Version 8

So, how is the world a more glorious place in version 8? What if I told you that you could do every bit of your own code without ever modifying any Kentico code? Pretty awesome, right? Let me show you how…

Let’s say we took the same custom page from above (because everyone needs page that tells the current time) and we wanted to integrate it directly into the Users module. With Version 8, almost every navigation element in the system is now data driven, as opposed to the hard-coded tabs of yesteryear. What this means is that it’s MUCH easier to add your elements directly to the UI without having to modify Kentico code. We will want this new page to be accessible directly within the Kentico User Module so it’s a nice, fluid experience for the user.

We will want the custom page to show up in the Kentico User module here:
 
 

1. Create a new page in the site (like above)

 

2. Edit the “Custom” module. In the module, go to the User Interface section.

 
 

 


3. In the User Interface section, navigate to the Users (global) / Users / Edit User section and add a new UI element. Set the Type as URL and the target to your custom file.

 


TIP

Adding the UI Element under the Users Global ensures it will be visible what site the users is logged into.

4. Go to the Users module and edit a user. Note the new element is listed on the left.

 


5. Click on the element find out the awesome time of day.

 


TIP

The Custom Module is a built-in module in v8 that you can use for adding your own code to Kentico modules. Kentico modules are by default “locked” and not editable. The Custom module allows you to add you own UI elements anywhere in the site without modifying these Kentico modules. You can find more on Custom Modules here.


Wrapping it Up

Pretty awesome, huh? Just like that you can add you own User utilities to the UI but never have to edit any Kentico code to do it!

Knowing the time is nice, but your code certainly will need to do more. I wanted to point out a built-in feature that will help you get contextual information in your custom modules. If you look at the actual link your new “Left Nav UI Element” creates, it contains the context of the user you are modifying.

http://localhost/Kentico8/CMSModules/Membership/Pages/Users/User_Edit_Custom.aspx?userid=53&objectid=53&action=edit

This is built into the navigation creation process. You can easily use this info and have a contextual information functionality in your custom code.

1. Update your custom code to use the edited user.

 

  


2. Amaze your friends.

 

That’s it! With this functionality you can extend the Kentico modules quickly and easily, while preserving the “Standard” codebase. This ensures your site can always get hotfixes and upgrades in the future. Good luck!
 

Author

Wiz E. Wig, Mascot & Director of Magic
Wiz E. Wig

Director of Magic