HomeGuides
Submit Documentation FeedbackJoin Developer CommunityLog In

Widget attributes

This topic describes the widget attributes.

B2B Commerce Cloud has a robust Content Management System that allows content editors and administrators the flexibility and control to design the look and feel of their website. Widgets are pre-configured content holders that allow you to rapidly add content to your pages without having to develop these elements. Widgets have a user interface that allow you to configure them to meet your needs.

The following steps show the general way to add a Widget to a site:

  1. Click Content Add, which opens the Add Widget menu.

  2. Choose the widget from the item Type, and select the template associated with the widget.

  3. Each widget has a CSS class assigned to it. You can change the CSS class on any widget.

Widget class definitions must inherit from AbstractWidget. Customize the display name by decorating the class with the DisplayName attribute. If a DisplayName attribute is not used, the class name, by spacing camel casing, will be used by default. So "ContactUsForm" would default to "Contact Us Form". This class then becomes the Model in the MVC view.

Use any one of the following attributes to decorate properties with pre-defined functionality. These properties will then generate the appropriate input fields when editing pages or widgets in the CMS.

[DisplayName("Form - Contact Us")]
        public class ContactUsForm : AbstractWidget
AttributeDescription
AllowedChildrenLimit an AbstractPage so that it can only have children of a type specified
AllowedParentsList of pages that the widget is allowed to be added to
CheckBoxContentFieldUses "CheckBox" template
DatePickerContentFieldUses "DatePicker" template, includes a property to set whether to include time on the date.
drop-downContentFieldUses "drop-down" template, contains a property for setting of values in the drop-down list
Enumdrop-downContentFieldInherits from drop-downContentFieldAttribute, adds an Enum type as a list of values for a drop-down list
FilePickerContentFieldUses the "FilePicker" template.  Allows setting of the ResourceType for the FilePicker, sets a default value of "UserFiles"
IntegerContentFieldInherits from TextContentFieldAttribute and sets the RegExValidation to enforce an integer value.  Currently being used on the NewsList page for setting a default page size
ListContentFieldUses the "List" template. Allows adding content that contains a list of items, such as: on the Contact Form Edit Content screen you can "Add" multiple email addresses and "Available Topics"
ListOfPagesContentFieldUses the "ListOfPages" template.  Currently used on a LinkList widget that displays a list of links to pages based on the pages found that are related to the "keys" found in the ListOfPages property
RichTextContentFieldUses "RichText" template
SelectContentItemTypeUsed inside a TemplatePage and used on the PageType property to set the type to a "ContentPage"
SelectedPageContentFieldUses on the ItemList (RootPageName property), ItemLink (LinkedContentName property) and NavigationList (RootPageName property) widgets.  Sets the Template to the "SelectedPage" template
TextAreaContentItemFieldUses the "TextArea" template.
TextContentFieldUses the "Text" template.  Lets you set a RegEx validation on the text template

These attributes are built into the B2B Commerce Cloud framework located in the InSite.Content.Attributes namespace. Additional attributes can be built and extended to provide custom functionality within B2B Commerce Cloud.

For example the RichTextContentField provides a textbox with WYSIWIG functionality.

Your message has been sent.

[RichTextContentField(IsRequired = true)]
            public virtual string SuccessMessage
            {
        get { return GetValue("SuccessMessage", "

The getters and setters for properties need to also make use of the methods GetValue and SetValue to properly persist data. FieldType.Contextual means the property value can vary by Context (Language, Persona, DeviceType). For fields that don’t need to vary by context, FieldType.General can be used.

", FieldType.Variant); }
            set { SetValue("SuccessMessage", value, FieldType.Contextual); }
            }
       ```

For example, Title needs to have a different value based on the current language.

It is possible to limit widgets by parent type. For example, the ZoneWidget can only be added to a TemplatePage.

For a given widget, such as RichContent, there can be one or more templates defined. If there is a need to create new functionality to display RichContent, an additional View could be added to the path of the RichContent folder.


Did this page help you?