A Rapid Development Framework for Community Server

Create Content Fragment.cst

Create Content Fragment.cst
posted by daveburke
11-17-2008


Downloads: 171
File size: 26.4kB
Views: 1,496

Creates the structure for a Community Server Sidebar Widget, or what is referred to in the SDK as a Content Fragment.

Property Descriptions

BaseCSApplicationType: Dropdown selection with options Drive, Blogs, Forums and MediaGalleries.  Drive denotes "nothing" here, otherwise the applications Components and Controls Using statements will be generated as well as a statement to create a instance of the current blog, forum or mediagallery, which is often one of the first statements in the fragment class AddContentControls() method.

ClassPrefixName: Prefix for widget class name. Ex: public class [Drive]ContentFragment : ConfigurableContentFragmentBase

RootClass: Root class of your custom project.  Ex: [DRIVE].Controls


Sample Generated Code

 


using System.Collections.Generic;
using System.Web.UI;
using CommunityServer.Components;
using Telligent.DynamicConfiguration.Components;
using RM = CommunityServer.Components.ResourceManager;
using CommunityServer.Controls;
using DRIVE.Components;
using CommunityServer.Blogs.Components;
using CommunityServer.Blogs.Controls;


namespace DRIVE.Controls
{
    public class AdvertiserContentFragment : ConfigurableContentFragmentBase
    {
        public override void AddContentControls(Control control)
        {
            Weblog blog = WeblogControlUtility.Instance().GetCurrentWeblog(control);

            //            List<DirectoryID> directoryIDs = DRIVEContext.Current.DirectoryIDs;
            //           foreach (DirectoryID _directoryID in directoryIDs)
            //            {
            //                SiteUrl url = new SiteUrl();
            //                url.UrlName = "weblogapplication";

            //                if (blog != null && _directoryID.BlogSectionID == blog.SectionID)
            //                    url.CssClass = GetStringValue("SelectedLinkCss", "SidebarLinkSelected");
            //                else
            //                    url.CssClass = GetStringValue("LinkCss", "SidebarLink");

            //                control.Controls.Add(url);
            //            }

            //            if (control.Controls != null && control.Controls.Count > 0)
            //            {
            //                control.Controls.AddAt(0, new LiteralControl(string.Format("<ul class='{0}'>",
                                 GetStringValue("URLCss", "CommonSidebarList"))));
            //                control.Controls.Add(new LiteralControl("</ul>"));
            //            }
        }

        public override string GetFragmentHeader(Control control)
        {
            return GetStringValue("fragmentTitle", FragmentName);
        }

        public override string FragmentName
        {
            get { return GetStringValue("fragmentTitle", RM.GetString("CF_DirectoryLinks", "DRIVE.xml")); }
        }

        public override string FragmentDescription
        {
            get { return RM.GetString("CF_DirectoryLinksDesc", "DRIVE.xml"); }
        }

        public override PropertyGroup[] GetPropertyGroups()
        {
            PropertyGroup[] propertyGroups = new PropertyGroup[] {
                new PropertyGroup("displayOptions", RM.GetString("Content"), 0),
                new PropertyGroup("displayOptions", RM.GetString("Style"), 1)
            };

            propertyGroups[0].Properties.Add(new Property("fragmentTitle", RM.GetString("CF_Title"),
                  PropertyType.String, 0, RM.GetString("CF_DirectoryLinksTitle", "DRIVE.xml")));

            Property p = new Property("URLCss", RM.GetString("CF_DirectoryULCss", "DRIVE.xml"),
                  PropertyType.String, 1, "DirectoryLinkList");
            p.DescriptionText = RM.GetString("CF_DirectoryULCssDesc", "DRIVE.xml");
            propertyGroups[1].Properties.Add(p);

            return propertyGroups;
        }

    }
}
Please sign-in to post a comment or question about this template or topic