August 16, 2011

Sitefinity 4 News Items Not Displaying Author Name

We just got through a minor issue involving NewsItems in a Sitefinity 4.1 implementation. The problem is that even though the administrators were specifying an author when creating NewsItems, THEIR NAME was being displayed instead of the author no matter what.

The solution is actually pretty straightforward - The layouttemplate for news items doesn't contain a field for author, even though it's entered on the back end. Instead it uses <sf:personprofileview runat="server"> which displays the first name and last name of the user posting the NewsItem. You'll have to go into the LayoutTemplate for single NewsItems (Design..WidgetTemplates...FullNewsItem in Sitefinity admin) and replace the personprofileview tag with the author name:

Default layouttemplate code:
<div class="sfnewsAuthorAndDate">
<asp:literal runat="server" text="<%$ Resources:Labels, By %>">
<sf:personprofileview runat="server">|<sf:fieldlistview format="{PublicationDate.ToLocal():MMM dd, yyyy}" id="PublicationDate" runat="server">

<div class="sfnewsAuthorAndDate">
<asp:literal runat="server" text="<%$ Resources:Labels, By %>">
<asp:Literal runat="server" Text='<%# Eval("Author")%>' /> | <sf:fieldlistview format="{PublicationDate.ToLocal():MMM dd, yyyy}" id="PublicationDate" runat="server">

Share |

August 10, 2011

ASP.Net Duplicate Section Defined Error - Is Only Defined Once

I had just set up a new local development environment for a solution already up and running in a staging environment.

The first time I tried to run the app, I got this error message:

Config Error There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section
Here are the exception details:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Detailed Error Information
Module IIS Web Core
Notification Unknown
Handler Not yet determined
Error Code 0x800700b7
Config Error There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined
Config File \\?\C:\SVN\TestSite\web.config

...but if you look in the web.config, the scriptResourceHandler is only defined once. However, if you're using .Net Framework 4.0, this entry already exists in the machine.config - hence the error. So the solution is, either remove this and other duplicate entries from your web config, or if it's an option, change your site in IIS from using the Framework 4.0 application pool back to the Framework 2.0 application pool.

Share |

August 04, 2011

Creating a Sitefinity 3.7 Custom ControlDesigner

Here’s a simplified summary of the process of creating a custom designer to edit properties for a Sitefinity control:

For simple text fields, edit fields are automatically generated just by exposing properties of type string on the user control.
...but for an elaborate field editing interface on a Sitefinity control here's a diagram and overview:
(apologies for the VB code :))
In App_Code
BaseControl.cs (contains the properties on our usercontrol we need to edit)
Inherits UserControl
ControlDesigner.cs (control displays the editing UI and sets the properties on BaseControl)
Inherits Telerik…ControlDesigner

The control itself must inherit from BaseControl.cs - this later allows it to be cast to type DesignedControl from the ControlDesigner.

It must also have a control designer specified as a class attribute. ex:

To layout the UI for the Control designer, you need to create a separate LayoutTemplate user control, and specify it’s path as the ControlDesigner’s LayoutTemplatePath property.

The ControlDesigner references the LayoutTemplate’s properties like:
base.Container.GetControl("litDataString", true)

and sets the property on the usercontrol like:
((DesignedControl)BaseControl).Data = “xyz”
For simpler, unstyled layouts, you can get away without a LayoutTemplate and just specifying the controls’ positions via css in the ControlDesigner.
Here’s a more in-depth Sitefinity walk-through and sample code.

Share |