Edit the file ~\CMSAdminControls\CKeditor\config.js and add the following code: config.scayt_autoStartup = true; directly above the config.toolbar code for the toolbar you are using. Please see the example below:
config.scayt_autoStartup = true;
config.toolbar_Full = config.toolbar_Default =
[
['Source', '-'],
['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', 'SpellChecker', 'Scayt', '-'],
['Undo', 'Redo', 'Find', 'Replace', 'RemoveFormat', '-'],
['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-'],
['NumberedList', 'BulletedList', 'Outdent', 'Indent', 'Blockquote', 'CreateDiv', '-'],
['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-'],
['InsertLink', 'Unlink', 'Anchor', '-'],
['InsertImageOrMedia', 'QuicklyInsertImage', 'Table', 'HorizontalRule', 'SpecialChar', '-'],
['InsertForms', 'InsertInlineControls', 'InsertPolls', 'InsertRating', 'InsertYouTubeVideo', 'InsertWidget'],
'/',
['Styles', 'Format', 'Font', 'FontSize'],
['TextColor', 'BGColor', '-'],
['Maximize', 'ShowBlocks']
];
-eh-
The Site map web part, as well as other navigation web parts, display the
DocumentMenuCaption field. If it is empty, the
DocumentName is displayed instead. If you need to let users define the caption on the Form tab, you can simply add a new system attribute to the document type in question which would represent the
DocumentMenuCaption. This way, all navigation web parts would display the value of the custom system field.
There might be times when you want one navigation web part to display a different field from other navigation web parts. Let's say that you have created a document type field
SiteMapTitle that you want to display using the Site map web part, while other navigation web parts should display the standard
DocumentMenuCaption field.
If this is your scenario, you can modify the
OnPreRender method of the Site map web part and change the
DocumentMenuCaption column for each row in the DataSet so that it contain a value of the
SiteMapTitle field:
if (this.smElem.DataSource is DataSet)
{
DataSet ds = this.smElem.DataSource;
foreach (DataRow row in ds.Tables[0].Rows)
{
row["DocumentMenuCaption"] = row["SiteMapTitle"];
}
}
-ml-
Kentico CMS provides a new customization model that allows you to modify each available provider very easily. For example, if you need to extend the shopping cart's content table and include a custom field that you have defined in the Site manager -> Development -> System tables -> edit COM_SKU table, all you need to do is to override the
CreateContentTableInternal and
CreateContentRowInternal methods of the
ShoppingCartInfoProvider class.
First, you need to call their base versions and then modify the returned
DataTable (in the
CreateContentTableInternal ) and
DataRow (in the
CreateContentRowInternal) as is demonstrated here:
protected override DataTable CreateContentTableInternal()
{
DataTable dt = base.CreateContentTableInternal();
dt.Columns.Add(new DataColumn("<column name>", typeof(<type>)));
return dt;
}
protected override DataRow CreateContentRowInternal(ShoppingCartItemInfo item, DataTable table)
{
DataRow row = base.CreateContentRowInternal(item, table);
row["<column name>"] = item.SKUObj.GetValue("<SKU field name>");
return row;
}
Then you can, for example, reference the custom field in the transformation, applied to the content table, by doing this:
{% ContentTable.ApplyTransform(String transformationName, String contentBeforeTransformationName, String contentAfterTransformationName) #% }
Links to other resources: E-commerce 6: New customization model, Transformations in macro expressions
-ml-
You can use a macro expression. The field names originate from the DiscountCoupon class (database table COM_DiscountCoupon).
Usage in the invoice template, therefore, would be:
{% DiscountCoupon.DiscountCouponCode #% }
for the coupon code, and in a similar way for getting other fields:
DiscountCouponDisplayName (probably the most informative), DiscountCouponValue, etc...
-zc-
To change customtable.oldname to customtable.newname:
First, rename the table using SQL Server Management Studio from “customtable_oldname” to “customtable_newname”.
Then, edit the custom table from
Site Manager -> Development -> Custom Tables and change the display name and the second part of the code name to newname.
Next, run the following SQL statement against your Kentico database:
UPDATE [CMS_Class]
SET [ClassTableName] = 'customtable_newname'
WHERE [ClassTableName] = 'customtable_oldname'
GO
Finally, edit the table from the Site Manager again and switch to the Queries tab. Update all of the queries to refer to the new table name.
-ag-
If you want to display the content you have entered in the
Default text property of your
Editable text web part to an editor’s field to make it editable on a Page tab, please open the
~\CMSWebParts\Text\editabletext.ascx.cs file and update the code as it is shown below. The code is located around the line 711 in the
LoadContent() method:
…
case CMSEditableRegionTypeEnum.HtmlEditor:
// HTML editor
if ((forceReload || (!RequestHelper.IsPostBack()) || (viewMode != ViewModeEnum.Edit)) && (this.htmlValue != null))
{
if (content == "") this.htmlValue.ResolvedValue = DefaultText;
else this.htmlValue.ResolvedValue = content;
}
break;
…
-jh-
If you want to display the URL address of a blog post which is related to a comment in
CMS Desk -> My desk -> Blogs -> Comments, please open the
~\CMSModules\Blogs\Tools\Comments_List.xml file and add an extra column into it:
<column source="CommentPostDocumentID" externalsourcename="PostDocument" caption="$general.url$" wrap="false">
</column>
The comment grid is now prepared to show URLs, but you need to fill that new column with the correct data, so please edit the
~\CMSModules\Blogs\Controls\Blogs_Comments.ascx.cs file and update the line 233:
gridComments.Columns = "CommentID, CommentDate, CommentApproved, CommentUserName, CommentText, CommentIsSpam, CommentPostDocumentID";
Finally you can get a document’s URL from its ID by adding an extra case into the
gridComments_OnExternalDataBound() method in the same file:
case "postdocument":
return CMS.CMSHelper.CMSContext.GetDocumentUrl(ValidationHelper.GetInteger(parameter, 0));
-jh-
Currently, you cannot delete license keys directly, but you can archive them instead. There is a
Archive button in the
Actions column, which can be used for this purpose. When a license key is archived, is not shown in the list anymore. However, you can still display them if you want, using the
Show archived keys checkbox. Furthermore, you can always
Unarchive it, which is the advantage of archiving when compared to deleting.
Particular options can be seen here:
-rm-
K# syntax allows you to apply transformations in macros. See here:
Transformations macro expressions for more details.
However, the
ApplyTransformation method does not work with all kinds of transformations.
Text/XML and
HTML type of transformations are supported. Others, regrettably, are not.
-hg-
To open the dialog window of your media gallery and have it display only regularly-used files, you can click on the small black arrow to collapse the properties frame.
At present, there is no property or setting for having this collapsed by default and you would therefore have to manually request it each time you open it, however you can simulate that extra click by using the following javascript:
$j(document).ready(function () {
$j('.DialogResizerArrowV').click();
});
To make it work in media galleries, please place it into the
~\CMSModules\MediaLibrary\Controls\MediaLibrary\MediaLibrary.ascx file.
-jh-
The Editable image web part is not designed to be used inside another web part. You can separate the web parts; use the original Editable image web part and the rest of code in a custom web part.
If you need to use the Editable image inside your custom web part, the parent web part must:
-
inherit from the CMSAbstractEditableWebPart class and
-
implement the LoadContent and GetContent methods.
You can take inspiration from the Editable image web part:
~/CMSWebParts/Text/editableimage.ascx.cs
-hg-
Some Kentico web parts will stop working if you use the standard jQuery linking in your custom web parts because they are using jQuery in some of their libraries. That’s why you need to use the jQuery noConflict version. Please check this link for more information:
http://docs.jquery.com/Using_jQuery_with_Other_Libraries
-bp-
In special cases you may need to generate html code and provide it as a web service. The example shows how to create a repeater control dynamically, configure its properties and return html code.
[WebMethod]
public static string GetDate()
{
Page pageHolder = new Page();
CMSRepeater rep = (CMSRepeater)pageHolder.LoadControl(typeof(CMSRepeater), null);
rep.ClassNames = "cms.article";
rep.Path = ".";
rep.TransformationName = "cms.article.default";
pageHolder.Controls.Add(rep);
StringWriter output = new StringWriter();
HttpContext.Current.Server.Execute(pageHolder, output, false);
return output.ToString();
}
-it-
If you are using aspx templates, it might happen that the custom filter does not work as you are used to in the portal engine and your data is not filtered.
<%@ Register Src="~/CustomFilters/CustomFilter.ascx" TagName="Customfilter" TagPrefix="cms" %>
<cms:Customfilter runat="server" ID="filter" FilterName="filtername" />
<cms:CustomTableDataSource runat="server" ID="datasource" SourceFilterName="filtername" CustomTable="....." />
<cms:CMSRepeater runat="server" ID="repeater" ... ></cms:CMSRepeater>
If this is your case, you will need to register the OnFilterChanged handler of the filter in the Page_Load method:
protected void Page_Load(object sender, EventArgs e)
{
filter.OnFilterChanged += new CMS.Controls.ActionEventHandler(filter_OnFilterChanged);
repeater.DataSource = datasource.DataSource;
repeater.DataBind();
}
and within the handler, bind the repeater control with the datasource as demonstrated here:
void filter_OnFilterChanged()
{
repeater.DataSource = datasource.DataSource;
repeater.DataBind();
}
Other resources:
Custom filter development
-ml-
As seen in the Developer’s Guide documentation
Creating ASPX Master Pages, you can use <%=DocType%> as your doctype declaration in your master pages. The default value is
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">. If you would like to change this, for instance to declare HTML5 (
<!DOCTYPE html>), you can do so in the code behind of your master page. In the
OnPreRender method of your master page codebehind (e.g., Root.master.cs), add a line defining
this.Doctype:
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
ltlTags.Text = HeaderTags;
// Declare the doctype as html5
this.DocType = "<!DOCTYPE html>";
}
-ag-
Regrettably, the nested macros are resolved too late for the condition. That is why the nested macros work for the branches of condition - (truevalue) and (falsevalue) parameters but not for the condition expression. If you want to compare two macros, please use custom macros. You can find a sample code here:
Macro expressions
Version 6 supports smarter system of macros: K#:
K# syntax
-hg-
You may need to display only products with images in a smart search result web part. To achieve this goal you need to follow these steps:
-
In the Site Manager –> Development –> System tables -> select Edit for table Ecommerce – SKU and go to the Search fields tab. Among these fields find SKUImagePath and check boxes Tokenized and Searchable. Do not forget to click on the OK button to confirm this change
-
As always, if some field definition is changed, you need to rebuild the index. Go to the Site Manager – Administration – Smart search and Rebuild the index. You need to make sure that Analyzer for this index is set to Simple.
-
Now you just need to configure the Search condition property in your smart search result web part. Its value should be: +SKUImagePath:getmetafile
Links to other resources: Using the smart search filter
-it-
This is typical for IIS 7 version and form controls which should do the postback. The solution is simple: you need to add/modify the following code to your web.config file:
<system.webServer>
...
<httpErrors existingResponse="PassThrough" />
<modules runAllManagedModulesForAllRequests="true">
...
</system.webServer>
Links to other resources: IIS 7 configuration
-it-
If you want to generate passwords as alphanumeric strings (without special characters) or as strings which contain only special characters, you can implement your own algorithm for password generation in the
~\CMSModules\Membership\Pages\Users\User_Edit_Password.aspx.cs file and in the
btnGenerateNew_Click method:
protected void btnGenerateNew_Click(object sender, EventArgs e)
{
// Check modify permission
CheckModifyPermissions();
string result = ValidateGlobalAndDeskAdmin();
if (result == String..Empty)
{
string pswd = ...; // your own algorithm
…
-jh-