CyberStore Ecommerce 2023 Documentation
LoadWidgetControl Class
Members  Example 


Dovetail.Ecommerce.Controls Namespace : LoadWidgetControl Class
A control to load widgets. Introduced in v2.16.
Remarks

The LoadWidgetControl is designed as a web developer's tool that handles reading a widget file's contents and then loading it into the control for placement within a CyberStore page.

Property Usage

By changing the values of the control's properties in the SitePages.config file for your Site, you can enable or disable certain behaviors, set certain defaults, alter aspects of the display or otherwise cusomtize your site's implementaion of the control.

The following describes properties pertaining to key functional areas of the control that can be configured to suit your needs.

The FileLocation property receives the location of the widget to load.
 
The following steps outline file loading processing based on the data in the FileLocation property.:
 
When no path is specified in the FileLocation (i.e. just a filename):

  1. The data provided will be used as a filename and the control will first look to see if it exists in the custom Widgets folder (as specified in the Site Manager > Site Configuration screen's Path tab) for the Site, and if found load it.
  2. If no matching filename is found in the site's custom Widgets folder, then the control will check to see if the filename exists in the /ecommerce/Widgets folder, and if so, load it.

When a valid relative path is specified:

  1. The control will search on the file to the appropriately mapped location for filename that matches, and if found, will load it.
  2. If no matching file is found then nothing will be loaded.

Web Developer Properties

In order to allow web developers the ability to deliver specific settings, or options into their widgets, a widget options JavaScript object can be used by the developer within the widget code. This object is named as a JavaScript variable with the name widgetOptions by default. To give your widget options variable a custom name you can set the OptionsVariableName property to any valid name you like.
 
Then the site implementer or designer can alter the value of certain options as a series of definable options can be sent to the widget using the Options property. Within the property provide options in a comma-separated list of standard JavaScript object form name:value pairs. These pairs will then be added the widget options object in the loaded page.
 
In a similar manner to the Options property, DeveloperOptions can be used to load options to the rendered page, but the values entered in DeveloperOptions will either be loaded to override the equivalent widget options object default properties and options delivered by the Options property when EnableDeveloperMode property has a value of true which makes it easy to have different settings in staging and production environments.

Web Developer Note:

The Options and DeveloperOptions property values must be able to be parsed as a standard JavaScript object therefore strings should be encapsulated using single quotes (') being sure to properly escape any  occurrences of the single quote character in the string value.

Finally, the read-only property OptionsID contains the value used for the unique name that will be assigned to the widget options object in the final rendered code as the string widgetOptions is replaced with the value in OptionsID to ensure that results are as expected when using multiple widgets on a single page.

Properties Inherited from the Base CyberStoreBaseControl

Properties specific to the CyberStoreBaseControl can be listed in the following categories:

Override Properties

When the IgnoreControl property is set to true, all processing of a control is skipped, and the control's Visible property is set to false ensuring that it is not rendered in the resulting CyberStore page.

Contextual Properties

Contextual properties define specific details about the current instance of the control based on context. Context can be set by any number of factors including the log in state of the Shopper, the Site being visited, or the properties that have been established for a control.

The AttributesBag property is used internal to control processing and is the collection of attributes, or properties, and their values based on how the control is configured. The attributes in this property are set by processing the SitePages.config file as well as any specific declared property values in any registered sub controls. It allows for the passing down of all properties to a control and any registered sub controls.

The ComConfigUserData and Site_ID properties are read-only values made available to all CyberStore controls to aid in processing and establishing context about the Site and Shopper.

Example
See an example of how to configure this control in SitePages.config.
<Control src="LoadWidgetControl.ascx" Name="BoughtWith Widget" 
    FileLocation="ItemsBoughtWith_Listing.html"
    OptionsVariableName="widgetOptions"
    Options="
        headlineText:'People who bought this, bought these too!', 
        photoWidth:120"
    DeveloperOptions="
        headlineText:'You may consider these hot sellers too!'"
    EnableDeveloperMode="false"
/>
Control Markup

The following is the markup for this control.

Developer's Note:

To create a custom version of the control, copy all of the code below into a file of the same name and place it into your Site's control folder (e.g., ../YourSiteFolder/Control). The CyberStore page engine will then override the default markup with your customized version.

 

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="LoadWidgetControl.ascx.cs"
    Inherits="Dovetail.Ecommerce.Controls.LoadWidgetControl" %>
Inheritance Hierarchy

System.Object
   System.Web.UI.Control
      System.Web.UI.TemplateControl
         System.Web.UI.UserControl
            Dovetail.Ecommerce.ControlBases.CyberStoreBaseControl
               Dovetail.Ecommerce.Controls.LoadWidgetControl

See Also

Reference

LoadWidgetControl Members
Dovetail.Ecommerce.Controls Namespace