Deliver superior customer experiences with an AI-driven platform for creating and deploying cognitive chatbots
Deliver Awesome UI with the most complete toolboxes for .NET, Web and Mobile development
Automate UI, load and performance testing for web, desktop and mobile
A complete cloud platform for an app or your entire digital business
Detect and predict anomalies by automating machine learning to achieve higher asset uptime and maximized yield
Automate decision processes with a no-code business rules engine
Optimize data integration with high-performance connectivity
Connect to any cloud or on-premises data source using a standard interface
Build engaging multi-channel web and digital experiences with intuitive web content management
Personalize and optimize the customer experience across digital touchpoints
Build, protect and deploy apps across any platform and mobile device
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.
Now that we've gone over Mapping External Templates for Sitefinity 4 Widgets, I thought it would be helpful to briefly review some of the benefits that are gained by using them in a new post in the 5 Things series.
The widget template editor within Sitefinity is a great for making quick edits to existing layouts and keeping all development inside one "box". However, if you're like me, you rely on Intellisense to keep the guesswork out of setting properties, and especially for writing code.
By developing your templates inside of Visual Studio, you gain the benefits of its rich Intellisense and code-completion, not to mention syntax and type checking and all the tools that come with the IDE.
As we discovered in the previous article Running Server-Side Code in Sitefinity Widget Templates , it is possible to write code inside the Sitefinity Template Editor. And again, for quick snippets or simple tasks it's probably best to just inject it right into the template. However, for more complex scenarios, it's usually better to separate this code into the code behind file.
This is especially true if you need to make use of multiple functions and handlers in your code. Using a code-behind file helps keep your project organized.
Internal Sitefinity widget templates are stored within the database. If your project is under source control, these templates cannot be versioned. By using external templates, you instead have physical files which you can version along with the rest of your code.
Since external templates exist outside the Sitefinity Administration, it's possible to make changes to them without having to login to the backend of your website. In addition, since they are not compiled into your web application, changes can be realized with a simple refresh of the page, rather than having to recompile the entire solution.
Because templates are mapping to a specific path, swapping out one template for another is trivial. You just need to make sure the active template has the name that matches the path set by in the widget properties.
For example, say you have a folder with four templates for events, one for each season. The active template for summer would have the name EventsListTemplate.ascx, while the others might be named something like EventsListTemplate_spring.ascx, EventsListTemplate_fall.ascx, and EventsListTemplate_winter.ascx.
When fall rolls around, rename the active template to EventsListTemplate_summer.ascx and rename the fall template to EventsListTemplate.ascx to make it the active template for the control.
The possibilities are further expanded by using the Virtual Path Provider described in the previous post. You can hook up templates and swap them on the fly as long as they match the Guid for the template.
I hope these recent articles on External Templates have helped give you ideas on how you can enhance your Sitefinity projects. If you've discovered a new benefit or trick for using external templates, share your feedback via our Sitefinity 4 Discussion forum.
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.
Copyright © 2018 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.