Loading

CMS On-site editing customization

Kentico allows to work with the content of websites through an on-site editing interface, which make it easy for editors to work with page content and manage documents directly while viewing the website from the live site perspective. In this post we will extend this functionality to be able to work with custom modules using the on-site editing interface.
 

Sometimes for convenience you may want to be able to edit information of some custom module through on-site editing interface - like you have ability to edit properties of current page in modal dialog. It is possible, even without modification of Kentico built-in controls and pages.

The first step is to identify what custom modules you want to be available through Kentico on-site editing interface. Then group selected modules under single UI element that can be placed under on-site editing UI element. Then we will need to create custom control that will display all necessary modules in drop-down menu and load this control dynamically using global events handling. So, let's go down to business and review all required steps in details.

First of all create a new module with code name, for example OnSiteEditCustom. Then on User interface tab, under CMS On-site editing UI element, we should create custom UI element (OnSiteCustomModules - code name) where we will place elements (names of modules) that should be available for on-site editing. As an example, for setting relations between regular custom module UI elements (those that are used in Kentico administration module) and those which are used for on-site editing, we will give them the same code name.

Then we should create control, to display list of modules available for on-site editing. As it is recommended by Kentico, we need to place this control to folder /CMSModules/OnSiteEditCustom/. Examples of .ascx file and code behind logic you can find below. For module's menu we will use existing UniMenu control that will be dynamically populated in code behind with set items in created module based on agreed relations. Modal dialog is used to display module's editing interface.

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CustomModulesMenu.ascx.cs" Inherits="CMSModules_OnSiteEditingCustom_CustomModulesMenu" %>
<%@ Register Src="/CMSAdminControls/UI/UniMenu/UniMenuButtons.ascx" TagName="UniMenuButtons"
    TagPrefix="cms" %>
<div class="ActionButtons">
    <cms:UniMenuButtons ID="otherMenu" ShortID="cmm" runat="server" EnableViewState="false" />
</div>
 
using System;
using System.Data;
using System.Web.UI.WebControls;
using CMS.Helpers;
using CMS.Modules;
using CMS.PortalEngine;
using CMS.UIControls;
using MenuItem = CMS.UIControls.UniMenuConfig.Item;
using SubMenuItem = CMS.UIControls.UniMenuConfig.SubItem;

public partial class CMSModules_OnSiteEditingCustom_CustomModulesMenu : CMSUserControl
{
    private const string ModalDialogScript = "modalDialog({0}, '{1}', '90%', '90%');";
    private const string OnsiteCustomModuleName = "OnSiteEditCustom";
    private const string OnsiteCustomElementName = "OnSiteCustomModules";

    protected void Page_Load(object sender, EventArgs e)
    {
        var cui = CurrentUser;

        if (cui != null)
        {
            UIElementInfo uiInfo = UIElementInfoProvider.GetUIElementInfo(OnsiteCustomModuleName, OnsiteCustomElementName);

            if (uiInfo != null && cui.IsAuthorizedPerUIElement(OnsiteCustomModuleName, OnsiteCustomElementName))
            {
                MenuItem customModuleItem = new MenuItem();
                customModuleItem.CssClass = "BigButton";
                customModuleItem.ImageAlign = ImageAlign.Top;
                customModuleItem.IconClass = "icon-app-modules";
                customModuleItem.Text = string.IsNullOrEmpty(uiInfo.ElementCaption) ? uiInfo.ElementDisplayName : uiInfo.ElementCaption;
                customModuleItem.Tooltip = uiInfo.ElementDescription;
                customModuleItem.ImageAltText = uiInfo.ElementCaption;

                otherMenu.Buttons.Add(customModuleItem);

                DataSet ds = UIElementInfoProvider.GetChildUIElements(OnsiteCustomModuleName, OnsiteCustomElementName);
                if (!DataHelper.DataSourceIsEmpty(ds))
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        string moduleUrl = GetRelatedElementUrl(ValidationHelper.GetString(dr["ElementName"], ""), ValidationHelper.GetInteger(dr["ElementResourceID"] , 0));
                        if(!string.IsNullOrEmpty(moduleUrl))
                        {
                            SubMenuItem subItem = new SubMenuItem();
                            subItem.Text = ResHelper.LocalizeString(ValidationHelper.GetString(dr["ElementCaption"], ""));
                            subItem.OnClientClick += GetModalDialogScript(moduleUrl, ValidationHelper.GetString(dr["ElementName"], ""));
                            customModuleItem.SubItems.Add(subItem);
                        }
                    }
                }
            }
        }

        ScriptHelper.RegisterDialogScript(Page);
    }

    /// <summary>
    /// Returns Url of related custom module UI element
    /// </summary>
    private string GetRelatedElementUrl(string elementName, int moduleId)
    {
        string moduleUrl = "";
        DataSet elements = UIElementInfoProvider.GetUIElements().WhereEquals("ElementName", elementName).And().WhereNotEquals("ElementResourceID", moduleId).Result;
        if (!DataHelper.DataSourceIsEmpty(elements))
        {
            DataRow elem = elements.Tables[0].Rows[0];
            ResourceInfo module = ResourceInfoProvider.GetResourceInfo(ValidationHelper.GetInteger(elem["ElementResourceID"], 0));
            if (module != null && ResourceSiteInfoProvider.IsResourceOnSite(module.ResourceName, CurrentSite.SiteName))
            {
                moduleUrl = UIContextHelper.GetElementDialogUrl(module.ResourceName, ValidationHelper.GetString(elem["ElementName"], ""));
            }
        }

        return moduleUrl;
    }

    /// <summary>
    /// Returns script string for displaying modal dialog.
    /// </summary>
    private string GetModalDialogScript(string url, string dialogName, bool useQuotesForUrl = true)
    {
        if (useQuotesForUrl)
        {
            url = "'" + url + "'";
        }

        return String.Format(ModalDialogScript, url, dialogName);
    }
}
 

When control is created, the next step is to display it on on-site editing toolbar. Global event handling is very useful here. Create class file in folder /App_Code/CMSModules/OnSiteEditCustom/. In the class we load created drop-down menu control using available event handlers and properties for UIToolbar control. Code sample of class is placed below. For more information on global event handling in modules, see: Initializing modules to run custom code.

 
using CMS;
using CMS.DataEngine;
using CMS.UIControls;
using CMS.UIControls.UniMenuConfig;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

[assembly: RegisterModule(typeof(OnSiteEditCustomModule))]
public class OnSiteEditCustomModule:Module
{
    public OnSiteEditCustomModule() : base("OnSiteEditCustom") { }

    /// <summary>
    /// Initializes the module. Called when the application starts.
    /// </summary>
    protected override void OnInit()
    {
        base.OnInit();

        UIToolbar.OnBeforeUserControlLoad += UIToolbar_OnBeforeUserControlLoad;
    }

    private bool UIToolbar_OnBeforeUserControlLoad(object sender, EventArgs e)
    {
        UIToolbar toolbar = sender as UIToolbar;
        if (toolbar != null)
        {
            toolbar.OnGroupsCreated += toolbar_OnGroupsCreated;
        }

        return true;
    }

    private void toolbar_OnGroupsCreated(object sender, List<Group> groups)
    {
        Group customModule = groups.Find(g => g.CssClass.Contains("OnSiteCustomModule"));
        if (customModule != null)
        {
            customModule.ControlPath = "/CMSModules/OnSiteEditCustom/CustomModulesMenu.ascx";
        }

    }
}
 

If you found this post useful please leave your comments below. Your feedback is very important for us.


Comments
Dissertation Writing Services Online
I have analyzed your article, it is unimaginably instructive and obliging for me.I respect the basic data you offer in your articles. A commitment of gratefulness is all together to post it
7/10/2017 3:33:33 PM

Reliable Essay Help
It takes after this all things considered recognized the truth that you 'can not fight with the fact of the matter is not thorough, everything has its outstanding case. A commitment of thankfulness is this data together for. Preferably you could don't stress over it share your points of view through more web content. For more data click here
7/10/2017 6:42:09 AM

Write my Coursework-EssayMall.co.uk
The writer has made an astounding article . You made your show and beside no investigate. It takes after this irrefutable truth that you can not fight with the fact of the matter is not extensive, everything has its prohibition. A commitment of thankfulness is all together for this data.
7/10/2017 6:17:16 AM

UK Essay Help
I really regarded circumspect it. Sitting tight for some more unlikely articles like this from you in the approaching days Someone do my exposition for me
7/10/2017 5:27:22 AM

Someone to Write My Essay
We're tremendous protectors of the Episerver content administration framework, which gives some unimaginably successful and versatile gadgets for site proprietors. One district that we're especially roused by the Episerver UI.
7/10/2017 4:51:42 AM

Essay Services
The initial step is to recognize what custom modules you need to be accessible through Kentico on location altering interface. At that point amass chose modules under single UI component that can be set under on location altering UI component.
7/8/2017 8:11:49 AM

www.essaycorp.co.uk
Some of the time for comfort you might need to have the capacity to alter data of some custom module through on location altering interface - like you have capacity to alter properties of current page in modular exchange. It is conceivable, even without alteration of Kentico worked in controls and pages.
7/8/2017 8:09:56 AM

Make My Accounting Homework
This a good way to appreciate the teacher as they put their efforts to train students. UK dissertation Writers appreciates the teachers.
6/30/2017 7:11:06 AM

Help With Programming Assignments
I really wanted to send a small word to say thanks to you for the fantastic points you are writing on this site.
6/30/2017 4:58:15 AM

majestic seo backlinks
Well writing articles will give you quality one way backlinks to your site. You have to write a lot in order to get this quality links.
6/20/2017 9:12:54 AM

Dissertation Writing
The hidden walk is to perceive what custom modules you ought to be open through Kentico on range adjusting interface. By then aggregate picked modules under single UI section that can be set under on zone modifying UI part. By then we should make custom control that will exhibit each basic module in drop-down menu and load this control consistently utilizing general occasions overseeing. Hence, we should go certified and concentrate every last required stroll in motivations behind interest.
6/19/2017 6:12:54 AM

Essay Service
I have scrutinized your article, it is particularly enlightening and obliging for me.I regard the essential information you offer in your articles. An obligation of appreciation is all together to post it.
6/19/2017 6:11:34 AM

Coursework Help Service
Hi, I have perused the majority of your posts. This post is presumably where I got the most helpful data for my exploration. A debt of gratitude is in order for posting, possibly we can see more on this. Are you mindful of whatever other sites regarding this matter.
6/19/2017 6:09:35 AM

know more
AcadGild is a technology education start-up AcadGild provides skill development courses based on current industry.Has anyone done a course of BigData from AcadGild? Need some reviews on ... Gulshan Vasnani I was looking for a job after finishing my engineering
6/15/2017 10:37:16 AM

Supernatural Dean Winchester Jacket Instylejackets
I truly appreciate just perusing the greater part of your site editing. Just needed to educate you that you have individuals like me who value your work. How ever you made an awesome showing with regards to by sharing these informations. A debt of gratitude is in order for sharing and please refresh some more data here.
6/15/2017 6:19:55 AM

Diya
Top Ten in Google Ranking You Can Find Our Beirut Escorts services Provider Escorts Agency Website in Google Top Ten We are Leading Beirut Escorts Provide and Fastest Growing Beirut Escorts Agency in Beirut , Lebanon , Our Lebanon Escort Girls are ready to serving you finest companion in beirut.
6/9/2017 9:27:34 AM

Aliya
Young , Dynamic And Most Promising Europe Award Winning Best Adult Escorts Services Provider Escorts Agency in Beirut with High Profile Models , Our Beirut Escorts Are Provide Finest Beirut Escorts Services in Beirut Our Beirut Escort Girls Provide High profile female escorts companion in beirut. <a href="http://www.fire-escorts-lebanon.com/">Beirut Escorts | Beirut Escorts Services</a>
6/9/2017 9:25:36 AM

vintage stores
Much appreciated you all that much to share these connections. Will look at this..
6/5/2017 8:14:53 PM

voyance amour
I can see that you are a specialist at your field! I am propelling a site soon, and your data will be extremely valuable for me.. Much obliged for all your help and wishing all of you the accomplishment in your business.
6/2/2017 9:01:51 AM

escorts beirut
New site is solid. A debt of gratitude is in order for the considerable exertion.
5/31/2017 5:11:51 PM

SpeedyEssay.CO.UK
The underlying stride is to recognize what custom modules you should be open through Kentico on area modifying interface. By then total picked modules under single UI segment that can be set under on area adjusting UI part. By then we ought to make custom control that will demonstrate each critical module in drop-down menu and load this control continuously using overall events managing. Thusly, we ought to go genuine and study each and every required walk in purposes of intrigue.
5/26/2017 8:53:01 AM

AssignmentDoer.CO.UK
I in addition agree with your post title and your genuinely well light up your point of view. I am especially lively to see this post. The custom sorts and fields in the flexible Content Type structure give each one of you flexibility to make your site in like manner as you need it. This is a to a remarkable degree edifying article. http://www.assignmentdoers.co.uk/
5/26/2017 6:18:39 AM

AssignmentDoer.CO.UK
I in addition agree with your post title and your genuinely well light up your point of view. I am especially lively to see this post. The custom sorts and fields in the flexible Content Type structure give each one of you flexibility to make your site in like manner as you need it. This is a to a remarkable degree edifying article. http://www.assignmentdoers.co.uk/
5/26/2017 6:18:21 AM

escorts in lebanon
Positive webpage, where did u think of the data on this posting?I have perused a couple of the articles on your site now, and I truly like your style. You're the best and please keep up the compelling work.
5/25/2017 4:56:30 PM

Assignment Service
I moreover concur with your post title and your truly well light up your perspective. I am particularly chipper to see this post. The custom sorts and fields in the versatile Content Type structure give every one of you adaptability to make your site likewise as you need it. This is a to an extraordinary degree enlightening article. http://www.proassignment.co.uk/
5/23/2017 12:27:47 PM

Showbox for android
Love what you're doing here guys, keep it up!..
5/23/2017 5:48:00 AM

assignment provider UK
My friend recommended this blog and he was totally right keep up the fantastic work about homework help
5/22/2017 5:50:25 PM

Case Study Help
Thanks for Nice and Informative Post. This article is really contains lot more information about This Topic.
5/22/2017 1:33:52 PM

lebanon escort
This online journal is so pleasant to me. I will continue coming here over and over. Visit my connection too..
5/21/2017 6:28:44 PM

GarageBand for windows 10
Apple GarageBand is a great music production studio for those who are looking for a software utility to help take their music production to the next level.
5/19/2017 10:52:40 AM

Professional Research Paper Writing Service
The custom sorts and fields in the adaptable Content Type structure give all of you flexibility to make your site similarly as you need it. This is a to a great degree instructive article. I furthermore agree with your post title and your genuinely well illuminate your viewpoint. I am especially cheery to see this post. http://www.researchpapertown.com/research-paper-writing-service
5/18/2017 7:16:00 AM

Diya
Young And Dynamic Seoul Escorts Provider Escorts Agency From Seoul, Star Seoul Escort Agency is provide you high profile and dynamice young girls for your companion , we are provide outcall seoul escorts services in seoul. Our seoul escort girls are almost above 18 years old and below 24 years old. So you can enjoy finest companion of seoul escorts in seoul. <a href="http://www.starseoulescort.com/">Seoul Escorts</a>
5/16/2017 9:09:16 AM

Purchase Essays Online
We're huge defenders of the Episerver content management system, which gives some incredibly effective and adaptable devices for site owners. One region that we're particularly inspired by the Episerver user interface.
5/15/2017 1:05:45 PM

Editing & Proofreading Service Online
The initial step is to distinguish what custom modules you need to be accessible through Kentico on location altering interface. At that point aggregate chose modules under single UI component that can be set under on location altering UI component. At that point we should make custom control that will show every important module in drop-down menu and load this control progressively utilizing worldwide occasions dealing with. Along these lines, we should go serious and survey every single required stride in points of interest.
5/11/2017 12:02:23 PM

Expert Research Paper Writers for Hire
The essayist has formed a splendid article. You made you show and almost no discussion about. It looks like this verifiable truth that you can not fight with the truth is not comprehensive, everything has its extraordinary case. An obligation of appreciation is all together for this information.
5/9/2017 9:49:36 AM

Dissertation Consulting Services Reviews
I essentially need to offer significant thanks for this magnificent post, quality article and will look a more noteworthy measure of your different enchanting substance. Splendid sharing!
5/9/2017 9:48:14 AM

Write my assignment
This is an extremely educational article. I additionally concur with your post title and your truly well clarify your perspective. I am exceptionally upbeat to see this post. A debt of gratitude is in order for imparting to us. Keep it up and share the all the more most related post.
5/9/2017 9:46:20 AM

Done Dissertation
I have examined your article, it is incredibly educational and obliging for me.I regard the critical information you offer in your articles. An obligation of appreciation is all together to post it..
5/6/2017 8:57:52 AM

bowselectie.com
Much appreciated you all that much to share these connections. Will look at this..
5/3/2017 5:57:40 PM

Followers-Like.com
So powefull.
4/28/2017 8:00:56 AM

Essay Writing Help
Create all you need. The custom types and fields in the flexible ContentType structure give you all freedom to make your site just as you need it.

Built upon Silex with Symfony components, Bolt is free and open source.

Frontend designers
Your design, your code.

Like to write clean markup and create your own templates?

Bolt uses Twig for its templates, an elegant, flexible and concise templating language, that allows you to write templates the way you want.

Content editors
Easy and powerful editing

The fully responsive dashboard works on desktop computers, laptops, tablets and mobile phones alike, so you can control anything from wherever you are.

You work with a team of editors? Bolt comes with a fully customizable structure for user levels.
4/28/2017 7:41:40 AM

youngfashionzone
I have perused your article, it is exceptionally instructive and accommodating for me.I respect the important data you offer in your articles. A debt of gratitude is in order for posting it..
4/24/2017 7:26:28 PM

topguntermpapers
I'm glad to see the great detail here!.
4/24/2017 7:25:52 PM

http://www.techiepaws.com/
Hello, I have browsed most of your posts. This post is probably where I got the most useful information for my research. Thanks for posting, maybe we can see more on this. Are you aware of any other websites on this subject.
4/23/2017 2:41:42 PM

Boxing Directory
I am definitely enjoying your website. You definitely have some great insight and great stories.
4/22/2017 7:45:54 PM

check this informative blog post
I can set up my new thought from this post. It gives top to bottom data. A debt of gratitude is in order for this significant data for all,..
4/21/2017 11:12:09 AM

escorts in lebanon
this is truly pleasant to read..informative post is great to read..thanks a considerable measure!
4/2/2017 6:05:57 AM

hoodie golf cart cover
including reasonable comments here...
4/1/2017 4:01:48 PM

shoe fall preventers
I can’t imagine focusing long enough to research; much less write this kind of article. You’ve outdone yourself with this material. This is great content.
3/22/2017 3:13:30 PM

ID Scanner
Adoration to peruse it,Waiting For More new Update and I Already Read your Recent Post its Great Thanks.
3/22/2017 3:04:16 PM

larry vickers
Awesome! It sounds great. A debt of gratitude is in order for sharing..
3/8/2017 7:29:45 PM

 Security code