FAQs >
Web parts & Controls
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-
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-
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-
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-
The Calendar web part in Departments uses a dynamic path according to the alias path of the department:
{ %cmscontext.currentdepartment.nodealiaspath#% }/Calendar/%
where the global calendar (displaying
Events) uses a fixed path (like
/Events/%). Please remove the spaces from the macro expression if you copy it.
To see the global Events in the department calendars, you can join the global event and department-specific event document paths and set the general path to the global scope.
Example department-specific calendar settings look like:
Path: /%
Where condition:
NodeAliasPath LIKE '{ %cmscontext.currentdepartment.nodealiaspath#% }/Calendar/%' OR NodeAliasPath LIKE '/Events/%'
Management of the calendar items will take place in the appropriate scope. You may also need to
modify some of the transformations, because clicking on the event details can take
you from a department calendar to the global one.
-zc-
Please navigate to the file \CMSWebParts\Viewers\Basic\UniPager.ascx.cs. Please change the line:
pagerElem.PageSize = PageSize;
for the following code:
if (CheckBox1.Checked)
{
pagerElem.PageSize = 1000;
pagerElem.PagedControl.PagerForceNumberOfResults = 1000;
pagerElem.PagedControl.ReBind();
pagerElem.DataBind();
}
else {
pagerElem.PageSize = PageSize;
}
Now add this method to the file:
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
SetupControl();
}
The last thing to do is to alter the file CMSWebParts\Viewers\Basic\UniPager.ascx and add the code below:
<asp:CheckBox ID="CheckBox1" runat="server"
oncheckedchanged="CheckBox1_CheckedChanged" AutoPostBack="true" EnableViewState="true"/>
Now you’ve added a checkbox which, when checked, will display 1000 results instead of the number set in the properties of the UniPager web part.
-bp-
Regrettably, the
Attachment image gallery contains a lightbox and more than one lightboxes on one page do not work together. You can use
Document attachments web part instead of
Attachment image gallery if you need more attachment web parts on one page.
Version 6 include
Repeater with lightbox and
Attachments with lightbox which can work in several copies on one page.
-hg-
If you want to view a SharePoint file using the handling file:
GetSharePointFile.aspx, please check the global settings in:
Site manager -> Settings -> Microsoft SharePoint
The settings configured here are automatically used for authentication by the
GetSharePointFile.aspx page. It is not enough to set up the credentials in the SharePoint web parts’ properties if you want to see the content of file (not to list only).
-hg-
Please
clone the Custom registration web part and add this line to the
SetupControl() method:
formUser.BasicForm.UseColonBehindLabel = false;
where
formUser is ID of a form control.
-hg-
Google maps key works only for one domain and you may have a problem with Google maps web part if you run your site on multiple domains.
In this case, please use this expression in the Google maps key property:
domain1.com=key1;domain2.co.uk=key2;domain3.org=key3
Actually there is a possibility to create folder for each user automatically while uploading file. It will be created regarding appropriate macro expression specified as follows.
Please follow steps below:
1. Please go to 'Media Gallery' webpart properties. Here you need to set 'Path' property using following macro: {%cmscontext.currentuser.fullname%}. Please note that if you click on 'Edit value' icon you can utilize the macro creator and use different user attribute to name the folder.
2. You might set 'Allow upload' to enable uploading within this webpart.
It will enforce that authenticated users will upload files to their independent folder within the media library.
Moreover it's also possible to set 'Destination Path' for 'Media File Uploader' webpart to work that way.
When you’d like to display webpart within one page template only on specific document, it’s possible to take advantage of ‘
Edit Value’ button in webpart properties. You can add following macro expression for ‘
Visibility’ property:
{%cmscontext.currentdocument.documentname|(equals)Home%}
Please note, you can place whatever document name instead of "Home". This will enforce that webpart will be shown on document with that name. You can find more about macros in our
Developer's guide.
You can use following example code to change property of web part (breadcrumbs) on some page template (cms.blog):
// get PageTemplateInfo according to PageTemplateCodeName
PageTemplateInfo pti = PageTemplateInfoProvider.GetPageTemplateInfo("CMS.Blog");
// get WebPartInstance according to WebPartID
WebPartInstance webPart = newInfo.GetWebPart("breadcrumbs");
// set web part property
if (webPart != null)
{
webPart.SetValue("Path", "/%");
}
// save changes to page template
CMS.PortalEngine.PageTemplateInfoProvider.SetPageTemplateInfo(newInfo);
Standard in-line control takes only one parameter. If you want to pass two parameters to any in-line control you can use following workaround. Your one parameter can consist of two parameters separated for example by underscore.
Example of BizForm in-line control with passing two parameters in one:
%% control:BizFormControl?BizFormName_AlternativeFormName %%
In code behind of your inline control you can simply parse this parameter into two strings and set your control properties according your needs.
You can also find alternative approach at
http://devnet.kentico.com/Knowledge-Base/API-and-Internals/How-to-pass-two-parameters-to-inline-control.aspx
Regrettably, web parts don't support multiple paths. However, you can mimic this behavior with a custom
WHERE condition if it is available. For example, the WHERE condition could look something like this:
NodeAliasPath like '/Articles/%' OR NodeAliasPath like '/Misc/%'
Please don't forget to set the path property to
/% to include all the documents into the query.
-bp-
To achieve your aim, you can use the following context macro expression within the
Culture code property of your Sitemap webpart:
{%currentdocument.documentculture%}
This will basically show only documents from current culture.
-ov-
The problem is in the CSS styles – there is set some background color for the enwrapping div. Set the
background for this element to
none. You can check the CSS class which is being used in your case using e.g.
Firebug add-on for Firefox or any other tool like this.
-ov-
We’ll see an example of
Submit button element of the
Logon form webpart. You can add your custom CSS class to the Logon input button following way:
1) Please open Logon form webpart properties. At the top of opened window there two tabs, right one is
Layout. Please switch to this one.
2) You will need to create new layout, in order to be able to edit it.
3) Once you use your custom layout you can add CssClass property to the button control, so that it can finally look like this:
<cms:LocalizedButton CssClass="LogonButton" ID="LoginButton" runat="server" CommandName="Login" ValidationGroup="Login1" EnableViewState="false" />
This will enforce adding CSS class to the input element which represents your button. Basically, you can change/add the CSS classes of other inputs (textboxes) the same way. Please note, this procedure is applicable also for other similar form webparts like Change password, Sign out button, etc.
-ov-
You may want to check the following settings:
- Make sure the "Show for document types" property value is empty and the "Document types" property is set to appropriate document type, such as "cms.news" (without double quotes).
- Make sure the "Transformation" value is set.
- If you specified any "Path" property value, set it to /% and test if it helps. If so, you may need to adjust the property value.
- If you specified any "Site name" or "Culture code" value, try to clear the values.
- If you specified any "Maximum nesting level" value, try to set it to -1.
- If you specified any "WHERE condition" value, try to clear it.
- Make sure the "Check permissions" value is set to false or - if you want to check the permissions - make sure that the current user has appropriate permissions.
Try to specify some validation group for your validation control.
When using ASPX templates and content subscription web part, you may get this error message: Please select some notification template for the specified events in the webpart settings.
Please edit the web part configuration and enter the template name in following format: SiteCodeName.TemplateCodeName
The source of the problem often lies in the fact, that users don’t fill in the
Document types property, which means that system uses the
View_Tree_Joined view (where the custom fields are not included) instead of a particular view based on the CMS.MenuItem document type. Although our listing webparts are designed to list CMS.MenuItems when this property is not defined, you need to populate the
Document types property to be able to display document type specific field values.
In short, entering the CMS.MenuItem value into the Document types property does the trick and should allow your custom fields to be shown properly.
-ov-
Even if you follow the
instructions for nested controls you can come up against a problem that it displays all documents under each item instead of the documents under the current item.
1. Please try to specify the path for the nested control like:
Path='<%# Eval("NodeAliasPath")+ "%" %>'
2. Set up the DelayedLoading and StopProcessing properties to true and add the code like:
<cc1:CMSRepeater DelayedLoading="true" StopProcessing="true" …
<script runat="server">
protected void Page_PreRender(object sender, EventArgs e)
{
repeaterId.StopProcessing = false;
repeaterId.ReloadData(true);
}
</script>
-hg-
Regrettably, this is a .NET bug. Please see this
forum thread.
You can find the solution there.
There are two possible reasons of this issue. First one is browser based and it is described in
this FAQ.
Second one could be caused by the fact, that the
‘Selected item transformation’ property of the Lightbox webpart is not set. In this case, there needs to be the image tag rendered when seeing selected items. For instance you can use our predefined
‘CMS.File.LightboxSelected’ transformation which contains code as follows:
<img src="<%# GetFileUrl("FileAttachment") %>" title="<%# Eval("FileName") %>" alt="" />
This transformation is intended for
CMS.File document type based documents, so if you store files any other way, you will need to adjust it as per your needs.
Links to other resources:
Writing transformations
Lightbox properties
-ov-
It is possible that you have changed the settings of
Content subscription web part. Please note that these changes are not applied for current subscriptions but only for new ones.
It would help if you re-new all subscriptions – delete them and create once again. You may delete them on
Administration -> Users -> edit -> Notifications tab.
There is a feature in 5.0 version that if you are a Global administrator you may log on as edited user (Administration -> Users -> edit -> General) so you may re-create his/her content subscriptions.
Documentation for Content changes notifications
If you check those properties (set them to true in ASPX templates) it may seems that links to previous/next and first/last items don’t appear on the page even though you would expect them to show up in the pager.
Actually it could be correct behavior, however one must admit it's a little bit confusing. Documentation says this: If checked, first and last buttons of the pager will be displayed only where usable. When you set DisplayFirstLastAutomatically to true it means that first/last links will be displayed only if there is no other possibility to reach the (first/last) page. It could be in the situations when you have set e.g. GroupSize to particular number and there is still page in another group of results.
The same applies to DisplayPreviousNextAutomatically likewise.
You can use following sample code:
<%# Eval("ClassName") %>
There must be transformations for pager specified as there is
Universal Pager used within this web part. You need to create transformations and then specify their name into properties with following names:
PagesTemplate
CurrentPageTemplate
SeparatorTemplate
FirstPageTemplate
LastPageTemplate
PreviousPageTemplate
NextPageTemplate
PreviousGroupTemplate
NextGroupTemplate
LayoutTemplate
You may optionally see sample transformations in this web part's configuration section at ~/Examples/Webparts/Full-text-search/Smart-search-dialog-with-results.aspx page in sample CorporateSite (the one based on Portal Engine).
You may insert the query to any document type, e.g. Root document type in:
Site manager -> Development -> Document types -> edit Root -> Queries -> New query
Then write this expression to Query name property of web part:
CMS.Root.<query name>
The reason of this behavior is an interference of JavaScript Frameworks, used by Scroling News web part and Lightbox web part. Scrolling news (and Content slider) web part is using a MooTools framework and Lightbox is using a Prototype framework. There is a problem with method with the same name in both frameworks. In current version (4.1) the only solution is to not using these 2 web parts on the same page template.
This issue may happen after upgrade, when you use custom layout in properties of web part and it doesn't correspond with the source code of new version of web part. Please create new layout from new version of web part to solve the issue.
You can write appropriate HTML code for lightbox directly into the transformation or e.g. static text or editable text web part. Please see example directly at
Lightbox site. Please note that the javascript libraries from ~\CMSWebParts\Viewers\lightbox_files folder are not original files - they are modified to work with the web part so it's not recommend using them for custom code. Could you please put original javascript libraries for lightbox e.g. into ~\CMSScripts folder and reference them instead of libraries from ~\CMSWebParts\Viewers\lightbox_files folder?
This error seems to occur randomly on larger files. The error is caused because the lightbox web part is trying to display an image “too fast” and the size of the image is not known at the given time. By increasing the “Load delay:” has the web part "more time" to gather the values. To fix this behavior increase this property value (250 by default) to 500 or higher in the properties of the lightbox web part.
Please find this file: ~\CMSModules\MessageBoards\Controls\MessageBoard.ascx.cs. You need to edit line about 443 setting ORDER BY condition for datasource:
this.rptBoardMessages.DataSource = BoardMessageInfoProvider.GetMessages(where, "MessageInserted DESC");
By default, Content Before and Content After web part properties are not defined in CMS Site Manager -> Development -> Web parts -> edit your web part -> Properties section and therefore you are not able to specify default value of these properties. However, if you simply add new web part property with Attribute name = ContentBefore or ContentAfter, you will be able to specify default value for these properties.
You can enable requirement of e-mail filling for Forum posts in CMSDesk -> Tools -> Forums -> …please edit some Forum group or even single Forum in some group.
Then on "General" tab, check the "Require e-mail address" setting.
Please open ~/CMSAdminControls/FCKeditor/editor/js/fckeditorcode_gecko.js file and find and change following string:
G='<br type="_moz">';
to:
G='';
Unfortunately, this seems to be a bug in the Kentico CMS version 4.0. We are very sorry for this inconvenience. We will fix it in the nearest version.
In a meantime you can solve the issue by adding following lines into SetupControl() method in ~\WebParts\Viewers\randomdocument.ascx.cs file:
this.repElem.CacheMinutes = this.CacheMinutes;
this.repElem.CacheItemName = this.CacheItemName;