Recently I’ve been receiving requests for help with the installation of the Template Importer module included in the Sitefinity SDK into an existing Sitefinity project. I’ve decided to create a blog post and a video to record the whole process.
Generally, the steps that I will list below could be followed to attach any module from the SDK to an existing Sitefinity project.
In some cases there is an additional step (including SampleUtilities as an additional project to your solution), but you’ll most probably get this as a prerequisite in the description of the module in the SDK.
So here is what I’m doing in this video:
- Start the SDK browser;
- Extract the Template Importer project in a folder (it’s going to extract a Sitefinity web application as well, therefore the SDK will prompt you to insert a valid license – trial or commercial);
- Copy the extracted TemplateImporter project from the folder we just created to the Projects folder your project manager is creating your Sitefinity websites in;
- Open your current Sitefinity project with Visual Studio
- Add the template importer as an existing project to the current solution;
- Next we have to do some reference substitution. Currently the Template importer contains some dll-s, which are referenced from a source we won’t use anymore. We need to remove them and reference the same dll’s from our project we are plugging in the template importer into. Delete these references:
- Telerik.Web.UI Now “Add References” to the template importer, browsing through the bin folder in your Sitefinity project and choosing the same dll files from there.
- Add a reference to the TemplateImporter project from your Sitefinity project. This way a TemplateImporter.dll will appear in the bin folder of your Sitefinity project.
- Build your project.
It is possible at this point to run into a couple of exceptions if you are using an older version of the Sitefinity SDK with a newer version of Sitefinity. I will address these at the end of this blog post.
- Go to the administrative backend of Sitefinity ->Administration->Settings->Advanced->System->ApplicationModules -> Create new
- Fill in the fields like this:
- Name: TemplateImporter.TemplateImporterModule
- Title: TemplateImporterModule
- Description: TemplateImporterModule
- Global resource class ID: TemplateImporter.Localization.TemplateImporterResources
- Type: TemplateImporter.TemplateImporterModule
- StartupType: OnApplicationStart
- Save your changes and restart your application or recycle your application pool. At this point the template importer should appear under the Design section and should be ready for use!
N.B. Possible issues that could come up:
- During compilation, you might get this error: 'Telerik.Sitefinity.Modules.Libraries.MediaContentExtensions.Images(Telerik.Sitefinity.Libraries.Model.Album)' is a 'method', which is not valid in the given context in the file TemplateImporter.cs in this line:
var image = album.Images.Where(i => i.Title == Path.GetFileName(imageName) && i.Status == ContentLifecycleStatus.Live).FirstOrDefault();
The problem is derived from the fact that Images is no longer a member, but a method, so you should add brackets (), like this:
var image = album.Images().Where(i => i.Title == Path.GetFileName(imageName) && i.Status == ContentLifecycleStatus.Live).FirstOrDefault();
- When running the Template Importer, you might stumble on a “Wrong Reference Version” error in this file : TemplateImporterControl.ascx If so, open it in your Visual Studio, and locate this line:
<%@ Register Assembly="Telerik.Web.UI, Version=2012.1.215.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
Remove the Version information, like this:
<%@ Register Assembly="Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
Now build your application. That should do it!