The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.
Thank you to all who attended today’s webinar. Below are the resources mentioned during the webinar including the video, code snippets and the downloadable project.
This code can be used to make your admin controls fit nicely inside Sitefinity, resembling other built-in modules with a consistent look and feel.
<h1 class="sfBreadCrumb"> <!-- Page Title --> </h1> <div class="sfMain sfClearfix"> <div class="sfMain sfClearfix"> <div class="sfAllToolsWrapper"> <div class="sfAllTools"> <div class="sfActions"> <!-- Toolbox --> </div> </div> </div> <div class="sfWorkArea sfClearfix"> <div class="rgTopOffset"> <!-- Workspace --> </div> </div> </div> </div>
If you want to add a “Create” button that resembles that of other modules, use the following code in the toolbox area.
<ul> <li class="sfMainAction"><span>
<a class="sfLinkBtn sfNew" href="#">
<span class="sfLinkBtnIn">Create Item</span></a>
</span></li> </ul>
This method simplifies installation of multiple pages for your backend administration.
/// <summary> /// Creates the page. /// </summary> /// <param name="pageManager">The page manager.</param> /// <param name="pageID">The ID of the page to be created.</param> /// <param name="parentPageID">The ID of the parent page under which to create the new page.</param> /// <param name="UrlName">Name Url used to access the page.</param> /// <param name="ShowInNavigation">if set to <c>true</c> [show in navigation].</param> /// <param name="Title">The page title.</param> /// <param name="control">The web User Control to add to the page.</param> private void CreatePage(PageManager pageManager, Guid pageID, Guid parentPageID, string UrlName, bool ShowInNavigation, string Title, PageControl control) { // get backend node var parentPage = pageManager.GetPageNode(parentPageID); // Create a node in the SiteMap for that page. var node = pageManager.CreatePageNode(pageID); pageManager.ChangeParent(node, parentPage); parentPage.Nodes.Add(node); // set page properties node.RenderAsLink = true; node.Title = Title; node.ShowInNavigation = ShowInNavigation; node.UrlName = UrlName; // Create a PageData object to hold the actual page contents var pageData = pageManager.CreatePageData(); pageData.Template = pageManager.GetTemplate(SiteInitializer.DefaultBackendTemplateId); pageData.HtmlTitle = Title; pageData.Title = Title; pageData.Status = ContentLifecycleStatus.Live; pageData.Visible = true; pageData.Version = 1; //associate the node with the PageData object node.Page = pageData; // add admin control to the page if (control != null) pageData.Controls.Add(control); }
This code will install a widget into the “Page Controls” toolbox.
// get section from toolbox var config = initializer.Context.GetConfig<ToolboxesConfig>(); var pageControls = config.Toolboxes["PageControls"]; var section = pageControls .Sections .Where<ToolboxSection>(e => e.Name == ToolboxesConfig.ContentToolboxSectionName) .FirstOrDefault(); // add widget to section if it doesn't exist if (!section.Tools.Any<ToolboxItem>(e => e.Name == TestimonialsView.ViewName)) { var tool = new ToolboxItem(section.Tools) { Name = TestimonialsView.ViewName, Title = "Testimonials View", Description = "Public control for the Testimonials module", ControlType = "~/Modules/Testimonials/TestimonialsView.ascx", CssClass = "sfTestimonialsWidget" }; section.Tools.Add(tool); }
Errors
While developing your module, you may encounter the error “Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information”.
This problem can occur if you are modifying existing classes in your project as they may be cached in Sitefinity.
Rebuilding and restarting your website, as well as deleting your browser cache should resolve this issue
A previous video exploring a basic intra-site module is available that explains how you can create an “Installer Page” as well as an uninstaller that will automatically delete all pages and unregister the module from Sitefinity.
This article is available here: Creating Intra-Site Modules in Sitefinity 4
There were a few requests to see the example using OpenAccess. To see how easily you can convert this project to use OpenAccess instead of Entity Framework, take a look at this article: Building Data Layers Quickly with OpenAccess.
A zip file containing the example code is below. This is just the module code and should be extracted into an existing Sitefinity website. If you don’t have one, be sure to register for a free trial.
View all posts from The Progress Team on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.
Let our experts teach you how to use Sitefinity's best-in-class features to deliver compelling digital experiences.
Learn MoreSubscribe to get all the news, info and tutorials you need to build better business apps and sites
Progress collects the Personal Information set out in our Privacy Policy and the Supplemental Privacy notice for residents of California and other US States and uses it for the purposes stated in that policy.
You can also ask us not to share your Personal Information to third parties here: Do Not Sell or Share My Info
We see that you have already chosen to receive marketing materials from us. If you wish to change this at any time you may do so by clicking here.
Thank you for your continued interest in Progress. Based on either your previous activity on our websites or our ongoing relationship, we will keep you updated on our products, solutions, services, company news and events. If you decide that you want to be removed from our mailing lists at any time, you can change your contact preferences by clicking here.