CMSEditModeButtonAdd
The CMSEditModeButtonAdd control displays a button that allows content editors to add new pages. The button only appears in the Edit mode of the Pages application and in On-site editing mode.
Getting started
The following tutorial shows how to display a button that creates new news pages on an ASPX page template:
Create a new ASPX page template.
In Visual Studio, drag the CMSEditModeButtonAdd control from the toolbox onto the page template’s form.
Set the following properties for the control:
- ClassName: CMS.News
- Path: /News
<cms:CMSEditModeButtonAdd ID="CMSEditModeButtonAdd1" runat="server" Path="/News" ClassName="CMS.News" />
This tells the control what type of pages to create and sets the path of the page under which the pages are added.
Switch to the template’s code behind and using statements referring to the following namespaces:
using CMS.PortalEngine; using CMS.Helpers; using CMS.DocumentEngine.Web.UI; using CMS.Base.Web.UI;
Add the following code to the Page_Load method:
// Registers the edit mode button script if (!PortalContext.ViewMode.IsLiveSite()) { ScriptHelper.RegisterClientScriptBlock(this, typeof(string), ScriptHelper.EDIT_DOCUMENT_SCRIPT_KEY, CMSControlsHelper.EditDocumentScript); }
The code above is required if you wish to use the control individually on an ASPX page template.
Create a page based on the template in the Kentico administration interface.
If you view the page in the Edit mode of the Pages application, the control displays a button that allows you to add news pages.
Clicking the button redirects you to the form where you can create the news pages.
Configuration
You can set the following properties for the CMSEditModeButtonAdd control:
Property name |
Description |
Sample value |
ClassName |
Specifies the page type that the control creates. |
“cms.article” |
Path |
Alias path of the parent page under which the control creates the new pages. If omitted, the control adds pages as child pages of the page containing the control. |
“/whitepapers” |
StopProcessing |
If true, the control stops all processing — does not load or display any data or other HTML output. |
|
Text |
Sets the caption of the button. If not set, the default text is “Add new”. |
“Add new article” |
Appearance and styling
The appearance of the CMSEditModeButtonAdd control is determined by the CMSEditModeButtonAdd CSS class.
The recommended place to define the class is in a Kentico stylesheet using the CSS stylesheets application.
You can apply stylesheets to:
- Entire websites
- Individual pages that contain the control