Navigatie

Contact

Send mail to the author(s) E-mail

View Richard Soeteman's profile on LinkedIn

RSS 2.0 | Atom 1.0 | CDF

Archief

Categorieën

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Sign In

Zoeken

# Tuesday, 15 November 2011
Tuesday, 15 November 2011 16:05:32 (GMT Standard Time, UTC+00:00) ( CMSImport | Umbraco )

This Blog is not active anymore, further posts will be available on my company website. Read new posts here

A question I get a lot is how to solve date formatting issues in CMSImport. Unless you are using SQL Server all imported values are of type string. So when you try to import date values the data layer will try to convert the value to a DateTime object, if it can’t parse the string you will see an error. These errors can be solved. Let’s take the following example from a Wordpress export file that can fail.

<wp:post_date>2011-11-03 17:29:18</wp:post_date>

When mapping the value in CMSImport you can select the advanced mapping option, this will show the following mapping options if you map against a DateTime Property. As you can see you can specify a date format. Check the custom date formatting section for the exact formatting syntax. When you specify a format that exactly matches the string from your datasource(TIP use the refresh option to update the preview) CMSImport will use that format to convert the string to the DateTime object and all will import fine.

clip_image002

Hope this helps you!

Comments [0] | | # 
# Tuesday, 08 November 2011
Tuesday, 08 November 2011 10:16:29 (GMT Standard Time, UTC+00:00) ( Package | Umbraco )

This Blog is not active anymore, further posts will be available on my company website. Read new posts here

Last week Matt Brailsford released uGoLive. uGoLive is a package with essential checks you need to do before your website goes live.Test includes checking for debug and trace mode, removing install directory etc. The great thing about uGoLive is that you can easily integrate checks into uGoLive. In fact you can already use or extend the uGoLive contrib project. But you can also integrate uGoLive into your own package. Extending uGoLive is very well documented,  I’ve just integrated uGoLive into the SEO Analyzer package I am working on.

SeoAnalyzer uGoLive

It’s all about plugin architecture

The thing I like most about Umbraco and most of the available packages is that is uses a plugin architecture. Plugin architecture means that Umbraco or a package defines an interface, or attribute and when you implement that interface, or decorate your class with the attribute in your own code it will be picked up automatically by Umbraco or the package. This also prevents you have a tight coupling with the functionality you want to implement. In other words when you add a class implementing a certain interface this will be automatically picked up when the responsible functionality in this case uGoLive exists in the Umbraco environment. If uGoLive isn’t installed it’s just a class that does nothing.

To integrate the custom checks as displayed in the above example I only added a reference to the Our.Umbraco.uGoLive.dll, decorate my class with the Check attribute and implement a class deriving from AbstractCheck for each check.

 /// <summary>
    /// Check the SEO Analyzer table for template issues
    /// </summary>
    [Check("C4B4D282-12CB-44AC-8263-389D70415895", "Template issues", "Leaving SEO Issues in templates unsolved can be bad for your ranking", "SEO Analyzer")] 
    public class SeoAnalyzerTemplateErrorsCheck : AbstractCheck
    {
        /// <summary>
        /// Checks the SEO Analyzer error log table
        /// </summary>
        public override CheckResult Check()
        {
            return TemplateIssues.GetAll().Count == 0 ? PassedResult() : FailedResult();
        }

        /// <summary>
        ///Returns the result object when the check passed
        /// </summary>
        private CheckResult PassedResult()
        {
            var result = new CheckResult();
            result.Status = CheckResultStatus.Passed;
            result.Message = "No template issues found";

            return result;
        }

        /// <summary>
        ///Returns the result object when the check failed
        /// </summary>
        private CheckResult FailedResult()
        {
            var result = new CheckResult();
            result.Status = CheckResultStatus.Failed;
            result.Message = "Template issues found, resolve them in the SEO Analyzer section";

            return result;
        }
    }

This was very straight forward to implement, a big #h5yr to the team who build uGoLive and now I better hurry up finishing SEO Analyzer to prevent you from having SEO issues in your site.

Comments [0] | | # 
# Tuesday, 25 October 2011
Tuesday, 25 October 2011 13:25:49 (GMT Daylight Time, UTC+01:00) ( CMSImport | Umbraco )

This Blog is not active anymore, further posts will be available on my company website. Read new posts here

 

 cmsimport

A few weeks back  I’ve released CMSImport 2.1. Apart from the awesome Logo made by Arnold Visser I’ve added some functionality as well.

Import dashboard for Content Editors

CMSImport is great for developers. They can create import definitions and execute, or schedule  them. When you want to allow your content editors uploading new data and import that data you need to allow them access to the developer section, or let them upload a file to a specific location and schedule a task that imports that file very hour or so. Well not anymore. Now  you can use a dashboard control and allow users to import their data using that dashboard control. The user can select an import definition, upload a file containing the data to import and optional upload a zip file containing the media files. Before importing the data will be verified to ensure all columns still exists in the new uploaded data file. This feature is a direct request from customers who use CMSImport to update their TeaCommerce or uWebshop catalog, but can also be used for any other import requirement of course.

importdashboardcontrol

As a developer you still have full control what you want your users to import. Using the ImportDashboard settings page you can enable/disable Import definitions you want your end users to use. You can only select import definitions that allow upload of a file such as Excel, Csv, Xml etc. You will also see an xml Snippet you can customize to your needs and paste into the dashboard.config file. Using the access element you can also restrict which User types can access the Dashboard control.Check out this wiki for more information about configuring Dashboard controls.

UserImportSettingsDashboard

Finally support for Media using MNTP

With the 2.1 release it’s finally possible to upload media using the Ucomponents Multi Node Tree Picker. When you select advanced mapping options when mapping against a property based on the MNTP datatype you will see the following options screen. Set the media location where to store the media and files will be imported automatically. The benefit MNTP has over normal Media pickers is that you can use a comma separated string of media files you want to import instead of just one file. When mapping against a MNTP datatype you can only set media settings if the datatype is configured as a media picker, otherwise you will get a message that it is not possible to set the advanced options.

image

Comments [0] | | # 
# Monday, 17 October 2011
Monday, 17 October 2011 12:00:49 (GMT Daylight Time, UTC+01:00) ( Umbraco )

This Blog is not active anymore, further posts will be available on my company website. Read new posts here

 

Last week I was triggered by a tweet from Sebastiaan Janssen mentioning the Dictionary Section Package was broken in 4.7.1

dictionarytweet

Moving the Dictionary to a separate section  is a technique that I use myself a lot when building solutions for clients, I don’t want to give content editor access to the settings section and I really don’t want to edit Dictionary items myself .I just finished a custom section where I used this, so I immediately logged in as an Editor and indeed I got a nice Exception. This hasn’t happened before so I assume this security check is introduced in 4.7.x.

userException 

It seemed that the page was throwing this error and indeed the constructor of EditDictionary sets the CurrentApp which will be used  in a later stage to validate User permissions.

 public EditDictionaryItem()
 {
     CurrentApp = BusinessLogic.DefaultApps.settings.ToString();
 }

So to fix this error we only need to set the CurrentApp property to either language or empty string (no validation at all). The easiest way is to modify the source and recompile, but I never modify the original Umbraco source to work around the Umbraco core. This is because you need to update the source code for every version update of Umbraco. So I needed a way to update the CurrentApp property using my own code. Lucky for us asp.net is an object oriented language and  so we can add our own page and only override the constructor to modify the CurrentApp property. This can be done by creating a custom aspx page where the codebehind class derives from the EditDictionaryItem class.

    /// <summary>
    /// Derive from EditDictionaryItem to use the existing Dictionary functionality
    /// </summary>
    public partial class LanguageDictionary : EditDictionaryItem
    {
        /// <summary>
        /// Use the constructor to set the current app
        /// </summary>
        public LanguageDictionary()
        {
            CurrentApp = "language";
        }
    }

Unfortunately we still some page directives and markup in our aspx page. Lucky for us the original aspx file only contains some basic markup (a placeholder), controls are rendered from codebehind so it’s not a crime to copy and paste that markup and update the Page Directives to use our new codebehind and inherit from LanguageDictionary class. Below you see all markup.

<%@ Register Namespace="umbraco" TagPrefix="umb" Assembly="umbraco" %>
<%@ Register TagPrefix="cc1" Namespace="umbraco.uicontrols" Assembly="controls" %>
<%@ Page Language="c#" MasterPageFile="~/umbraco/masterpages/umbracoPage.Master" ValidateRequest="false"
    CodeBehind="LanguageDictionary.aspx.cs" AutoEventWireup="True" Inherits="DictionaryFix.LanguageDictionary" %>

<asp:Content ContentPlaceHolderID="body" runat="server">
    <cc1:UmbracoPanel ID="Panel1" runat="server" Width="408px" Height="264px">
    </cc1:UmbracoPanel>
    <script type="text/javascript">
        jQuery(document).ready(function () {
            UmbClientMgr.appActions().bindSaveShortCut();
        });
    </script>
</asp:Content>

So now we have a complete work around. Only thing is that this page will never be called from the tree. So we need to have a custom tree.The class responsible for rendering of Dictionary items tree  is the loadDictionary class. This class contains the Method RenderJS that renders the Javascript function to open the page. So we only need to override that method and point it to our new LanguageDictionary.aspx file, I store the aspx file in the already existing DigibizDictionarySection folder .

   public class LanguageDictionaryTree : loadDictionary
    {
        public LanguageDictionaryTree(string application) : base(application) { }

        public override void RenderJS(ref StringBuilder Javascript)
        {
            Javascript.Append(
                @"
                function openDictionaryItem(id) {
                UmbClientMgr.contentFrame('plugins/digibizdictionarysection/languagedictionary.aspx?id=' + id);
                }");
        }
    }

The last thing we need to update is the database table to use our new LanguageDictionaryTree  instead of the loadDictionary class. The database table to update is UmbracoAppTree , search for the row containing language as appAlias and update the treeHandlerAssembly and treeHandlerType values.

dbupdate

Copy the aspx page to the /umbraco/plugins/DigibizDictionarySection  folder and store the dll in the bin folder of your install. Then login as the editor again and see that you can access Dictionary items outside of the settings section again.

dictionaryfixed

Below you can find the links to the original package and the fix I’ve created. Jeroen Breuer mentioned he will implement this fix later in his package.

Comments [0] | | # 
# Tuesday, 06 September 2011
Tuesday, 06 September 2011 15:26:33 (GMT Daylight Time, UTC+01:00) ( mediaprotect | Package | Umbraco )

This Blog is not active anymore, further posts will be available on my company website. Read new posts here

Lots of people want to run MediaProtect on a Mysql database. Currently that is not supported but this is only because of a failing installer script for the MySql database. Benjamin Howarth wrote a MySql script for generating the log table in the MySql database. Once this table exists all functionality will work just fine on a MySql database. The next version of MediaProtect will support this out of the box, for now the installation procedure will be installing MediaProtect first and then run the following script to create the tables.

CREATE TABLE mediaprotectlog ( 
LogId BIGINT(20) NOT NULL AUTO_INCREMENT, 
MediaId INT(11) NOT NULL, 
Path VARCHAR(500) NOT NULL COLLATE 'utf8_general_ci', 
Protected BIT(1) NOT NULL, 
UserName VARCHAR(150) NOT NULL COLLATE 'utf8_general_ci', 
UserIP VARCHAR(50) NOT NULL COLLATE 'utf8_general_ci', 
LogDateTime DATETIME NOT NULL, PRIMARY KEY (LogId) )

Happy Installing!

Comments [0] | | # 
# Friday, 24 June 2011
Friday, 24 June 2011 11:08:03 (GMT Daylight Time, UTC+01:00) ( )

This Blog is not active anymore, further posts will be available on my company website. Read new posts here

Today I’ve officially released CMSImport 2.0, for those of you who don’t know what CMSImport is. In short CMSImport helps you import content or members from any datasource into Umbraco on a very friendly way. Just point to a datasource and add a mapping between fields in your datasource and the Umbraco  Content or Member properties. Currently CMSImport supports the following data sources by default (you can always create your own if you like):

  • Access Database
  • BlogML
  • CSV
  • Excel File
  • RSS Feed
  • SQL Server
  • WordPress Export file
  • XML

Access database and the Excel file Data source requires you to install the Microsoft Data Connectivity Components 

What’s new

This release is all about structured import of content. For example If you want to import a Product Catalog, you want to import Product Categories and Products. CmsImport 2.0 will help you with that by defining a Parent and child definition. Simply save the parent import definition and select “Create Child definition” from the context menu as displayed in the image below.  And you need to specify a Foreign key, that’s all!  This is very flexible, you can even mix data sources if you want to

childdefinition

Because CmsImport can import whole product catalogs it’s fully optimized to import ProductCatalogs for the Teacommerce and Uwebshop Ecommerce solutions. When you import BlogML or Wordpress data and you have Blog4Umbraco or the Blog starter kit installed You’ll see the Optimize for Blog4Umbraco/ Blog starter kit option. When you select this option, comments from BlogML or Wordpress will be imported automatically. Of course you can also skip this and Import Blogs and Comments separately.

blogml

Another major improvement is the Advanced Mapping feature. For each field you can add Advanced mapping options. CmsImport will determine the type of property and will give you some advanced options based on that type. For every property it’s possible to specify a default value, for some types it’s possible to specify more options. If you want to import Media it’s possible to put the media in the root of your Umbraco install and use the Advanced mapping options for a Media picker, or Rich Text editor to specify where to store the media in the Media Library. For a Media picker it’s even possible to select a default value from the Media Library instead of using a textbox.

advancerichtextmapping

I’ve also fixed the scheduled task functionality. In the previous version it ran 95% of the time. The other 5% it didn’t run because the Umbraco scheduler wasn’t active at the time it needed to execute the task, then one minute later the scheduler is running again but the scheduled task expired. This is solved now, the handler responsible for executing a scheduled tasks will also check for scheduled tasks that didn’t run at the requested date/time. if it finds an expired task it will run the task. To give you more insight when a scheduled task did execute I’ve introduced the scheduled task dialog. This reports when the task was scheduled and when it actually did execute. This dialog is  also reporting the next execute time.

scheduledtasklog

Umbraco Deli

Umbraco recently released the Deli. The Umbraco Deli allows you to download or buy products from a single source. CmsImport can be downloaded and bought through the Deli. CmsImport Pro comes in three editions:

  • Single domain license
  • Server license
  • Unlimited license

For customers that already bought a CmsImport Pro license from my site. First of all sorry for the manual order process Winking smile Very soon you will receive an email with a new license file that you can use for CmsImport Pro 2.0.

Free edition

Of course the free edition still exists and it had some small improvements. It’s now possible to use Advanced settings when you create a mapping so you can add default values for each field. Checkout the feature comparison sheet for all differences.

Demo

Enough text, time for some video Smile

If you want to discuss if CMSImport can handle your requirements, I can always demo or discuss features via Skype.Contact me via email (richard[at]soetemansoftware[dot]nl) if you want a remote demo. Or if you just want to use it download CMSImport from the Umbraco Deli.

Comments [2] | | # 
# Friday, 29 April 2011
Friday, 29 April 2011 13:06:57 (GMT Daylight Time, UTC+01:00) ( CMSImport | Umbraco )

This Blog is not active anymore, further posts will be available on my company website. Read new posts here

A question I get asked a lot is if it is possible to assign a template based on a datasource value. The answer is yes, normally the default assigned template will be assigned when importing your data and this is what 99% of the users want and expect. But using the RecordImported Event we can get the datasource value from the database and use that alias to map the template against the imported document.

Example

In this example we have some data coming from a database that we want to a standard Runway text page. Some items such as Integer and Donec are really important and we want to display these items in Pink. In Umbraco we added a new template called PinkTemplate and as you can see in the image below we added that Template alias in our Datasource that we are going to import.

Example data

As I mentioned earlier we can use the event system to manipulate the document during import . You can use the event system for CMSImport in the same way you use the normal Umbraco event system. In the example below you see that we derive from ApplicationBase and wire up the RecordImported event in the constructor. Since we only want to set the template during the initial import, we first check if the Importaction is  ImportAsNew. Then we need to check if the template column from the datasource is not null. You can access all  items from the datasource  using the e.Items collection. When the template column is not null, we get the template id from the database and assign that value to the document.

   1:  using CMSImport.Extensions.Import;
   2:  using umbraco.BusinessLogic;
   3:  using umbraco.cms.businesslogic.template;
   4:  using umbraco.cms.businesslogic.web;
   5:   
   6:  namespace AssignTemplate
   7:  {
   8:      /// <summary>
   9:      /// This class wil automatically assign a template to the document when being imported for the first time using the RecordImporting Event
  10:      /// If you want to use this class in your own project simply rename e.Items["Template"] to the template column you use
  11:      /// in your datasource
  12:      /// 
  13:      /// This code will work in both the Free and PRO edition of CMSImport and is written for version 1.2. 
  14:      /// If you have any questions please use the forum or email support@soetemansoftware.nl 
  15:      /// </summary>
  16:      public class AssignTemplateUsingDatasource : ApplicationBase
  17:      {
  18:          /// <summary>
  19:          /// Initializes a new instance of the <see cref="AssignTemplateUsingDatasource"/> class.
  20:          /// </summary>
  21:          public AssignTemplateUsingDatasource()
  22:          {
  23:              //Whenever a records gets imported 
  24:              ContentImport.RecordImported += new ContentImport.RecordImportedEventHandler(ContentImport_RecordImported);
  25:          }
  26:   
  27:          /// <summary>
  28:          /// When a record got imported this event is raised.
  29:          /// </summary>
  30:          /// <param name="sender">The imported document.</param>
  31:          /// <param name="e">The <see cref="CMSImport.Extensions.Import.RecordImportedEventArgs"/> instance containing the event data.</param>
  32:          private void ContentImport_RecordImported(object sender, RecordImportedEventArgs e)
  33:          {
  34:              //Only assign the value when its imported for the first time
  35:              if (e.ImportAction == ImportActions.ImportAsNew)
  36:              {
  37:                  Document doc = sender as Document;
  38:                  
  39:                  //Get the template value from the datasource. Datasource values are stored in the Items event arguments
  40:                  //Replace templateName with your column name in the datasource!!!
  41:                  string templateAlias = e.Items["templateName"].ToString();
  42:   
  43:                  if (doc != null && !string.IsNullOrEmpty(templateAlias))
  44:                  {
  45:                      //An alias is specified, try to get the template based on the specified alias  
  46:                      Template template = Template.GetByAlias(templateAlias);
  47:                      if (template.Id != null)
  48:                      {
  49:                          //Template is found assign it to the document
  50:                          doc.Template = template.Id;
  51:                      }
  52:                  }
  53:              }
  54:          }
  55:      }
  56:  }

When the import is finished you see that all items are imported and when you we take a look at the Integer document you’ll see that the assigned template is PinkTemplate instead of the default Runway Textpage template.

Pink template assigned

Why isn’t this supported in the UI?

As I mentioned before most people expect to assign the default value. When I include the assign template via datasource functionality in the UI it’s an option that you need to think about before setting or ignoring the option. My idea with CMSImport is that I want it to be a no brainer to use and introducing this option will make it a little bit harder to use. So if you want this I think it’s better to write 10 lines of code instead.

Downloads

Below you can download the complete source code. Change e.Items[“templateName”] to the column name you want to use in your project, build the project and add the DLL to the bin folder of your Umbraco install. That’s all!

Download the source code here

Comments [0] | | # 
# Wednesday, 27 April 2011
Wednesday, 27 April 2011 15:54:21 (GMT Daylight Time, UTC+01:00) ( mediaprotect | Package | security | Umbraco )

This Blog is not active anymore, further posts will be available on my company website. Read new posts here

Last month  I’ve released Media protect 1.0. Mediaprotect is an Umbraco  package that helps you protect media in the same simple way as you protect documents in Umbraco. Once the package is installed and you protect certain media, or content nodes, the files will be password protected. Only authenticated members can open the files, otherwise members will be redirected to the login screen.

The problem protecting media

No solution without a problem Winking smile. When you use Umbraco, by default all media items can be accessed directly. If you have a media item that you don’t want to be accessed and someone knows the url (maybe got a link via email from a friend), or you have a link in your content  to a media item that is crawled by Google and the user uses that url the media item will be shown/downloaded, if you like it or not.

This is also the case with upload fields on a protected content node. The page is protected but the uploaded file is not protected.

How Media protect solves this problem

Once you’ve installed media protect files on protected content nodes are protected by default and you’ll get the public access menu item on the context menu of your media section.

Best of all you don’t need to modify any existing media or document type, it just works!

The public access menu item  is the same menu item you get when you want to protect a node in the content section.

Public access

When you select Public access you’ll get the same dialog as you get when protecting content. You can specify if you want to use single user or role based protection. You can also specify the login and not authorized page.

Dialog

When you are finished protecting the media item, the media item gets a No Access sign. This indicates that the media is protected and can’t be accessed directly. When you open the media item and click on the document link you will be redirected to the login page since you are not logged in. Once you are logged in as a member and the member role is assigned as allowed roles to view the media item you can download the file.

protectedmedia

Compatible with Media Pickers and default asp.net Membership provider

It’s nice that we can easily protect media items but we also want to make sure that the editor doesn’t accidently pick protected files using a Media Picker, or in the Rich Text Editor. Media Protect will also display the same No Access sign when you want to pick a media item using a media picker or via the Rich text editor. Not only the default Umbraco pickers but media protect is also compatible with some 3th party pickers, such as Multi Node Tree Picker (The awesome picker from UComponents) and the DIgibiz Advanced Media Picker. Best of all if you have a custom media picker you can add the alias of that media picker to the mediaprotect.config file and it will be picked up automatically.

DIgibiz Advanced Media Picker

Speaking about compatibility. Mediaprotect is based on the default ASP.Net Membership provider, so you can use the default asp.net controls for logging in etc. and you can also use your own  custom membership provider.  Media Protect comes with a small API you can use in a .Net usercontrol/XSLT or Razor script to determine if an item is protected, or to determine if the current logged in user has rights to access the media node.

Free alternatives

Media protect is a commercial package, it protects your media out of the box(no need to change any document or media type , it just works).It will cost you 99 euro per domain though. If you want to protect media without spending money you might want to check out these free alternatives

More info and Download

If you want more info about Media protect I suggest you check out the product site. Here you find a video demonstrating the package and documentation. You can also download a fully functional free trial from our.umbraco.org. This will work on your local machine (localhost), only thing you get for free is a nice yellow sign that says you are running in Trial mode. The trial never expires and when you want to deploy your site you can buy a license for that domain or buy an enterprise license for your whole company.

Feedback

Please tell me what you think about this package. Like it, hate it? I would love to know.
Comments [2] | | # 
# Tuesday, 11 January 2011
Tuesday, 11 January 2011 13:31:15 (GMT Standard Time, UTC+00:00) ( CMSImport | Umbraco )

This Blog is not active anymore, further posts will be available on my company website. Read new posts here

Last week I’ve released CMSImport 1.2 (Pro). This was a minor release mainly to fix a few bugs

Change log:

  • Fixed string delimiter for csv files
  • Field adaptors on default properties didn’t get hit
  • Throw error when login is null for member import, otherwise you can’t create new members and Umbraco will throw errors on you.
  • Introduced a new FieldAdapter that can map user logins against a Member picker data type. CMSImport will auto convert this to the corresponding member id.
  • Tested against Umbraco 4.6 (beta)

Again this was a very small release. Mainly to fix some errors.

CMSImport 2.0

The most requested feature is structured import. I’m very happy to announce  that this will be included in CMSImport Pro 2.0. The video below demonstrates how this will work. I've tried to keep this as simple and flexible as possible and hope I have succeeded, if not I hope to hear from you.

CMSImport 2.0 Structured import demo from Richard Soeteman on Vimeo.

Other new functionality for 2.0

Of course structured import will not be the only new feature. Below you find a list of all other functionality that will be included

Support for more Data sources

CMSImport 2.0 will support new data sources to import from such as:

  • Rss
  • BlogMl
  • Wordpress export
  • Excel
  • MS Acces

If you have a specific product, or data format you want to import from please let me know through the comment form.

Configurable field adapters

In version 1.1 I’ve introduced field adapters. These field adapters are great to convert data from a data source to the format that is accepted by the Umbraco data type, but sometimes you need to specify some additional information. For example when you import data and want to map url’s against the Ucomponents Url picker you want to specify if the link needs to be opened in a new window or not. Currently that is only possible with a config file, not very friendly. In 2.0 it will be possible to specify some additional options like you have to do now when you import related media.

Support for third party packages

CMSImport 2.0 will come with support for third party packages such as UComponents, SuperSimpleWebshop,Teacommerce and Blog4Umbraco.

I’m sure there will be extra functionality added along the way.For now I hope you like what you’ve seen in the video and read in this post.
Comments [2] | | # 
# Wednesday, 24 November 2010
Wednesday, 24 November 2010 10:37:54 (GMT Standard Time, UTC+00:00) ( CMSImport | Umbraco )

This Blog is not active anymore, further posts will be available on my company website. Read new posts here

Ok official it was  released in the beginning of October, but the manual wasn’t finished and I couldn’t upgrade existing clients to 1.1. From a customer satisfaction point of it was very important for me to have these things ready before blogging about all the cool new features. So what’s new?

Media Import

The main feature that is added to CMSImport PRO is the ability to import media related to content or member data. This isn’t a separate import process but integrated in content or media import. When CMSImport finds a reference to a relative path it will try to get the item and convert it to a media item, or store it in the media folder in case of an upload field. The only required thing is that the original media folder is copied to the root of your Umbraco folder.

In the example below the img folder of the original site containing two images is stored in the Umbraco root.

filesystem

In the Import wizard you can specify that you want to import media items also. Check the option “Import content related media”. If you want to map media against media pickers and/or the TinyMCE editor, you need to specify a media folder also. CMSImport will keep the imported folder structure.

mediaimportoptions

Then in the next step you can create the mapping like you would normally do.

mediamapping

  1. When a reference to an image is found in the content, CMSImport will create a media Item and update the image source to the new Media item(Currently only images are supported in Rich Text. Version 1.2 will have support for files also. Media Pickers and Upload fields will work with files also.)
  2. When an image (could also be a file) reference is mapped against an upload field. CMSImport will store the image in the Umbraco Media folder and update the reference in the Upload field
  3. When an image (could also be a file) reference is mapped against a media picker. CMSImport will create a media item and store the Id of the media item .

When the import process is finished you’ll see that the media items are imported

mediaimported

And when you open an imported item in the content section you’ll see that all the references are updated to the imported media items

contentupdated\

Again you don’t need to do anything extra apart from downloading the original media folder to you Umbraco Install.

Currently this import process will work for the following datatypes:

  • Upload Field
  • Media Picker
  • TinyMCE (Rich text editor)

In future releases CMSImport will support custom datatypes and File import for the TinyMCE datatype also.

FieldAdapters

FieldAdapters are used to convert original values from the datasource to a value the DataType expects. In previous versions when you wanted to import boolean data from a CSV file and map that against a true/false dataType, it would have failed because the True/False datatype could only handle the integer values 1/0 or a real boolean.

FieldAdapters fix those issues. During import of a field CMSImport will check based on the underlying datatype if a value can/must  be converted.

The following snippet contains the implementation of the BooleanFieldAdapter( just to show how little coding is needed for a better import experience).  It will add a relation to the True/False dataType based on the DataTypeID property . This must be the same GUID as the True/False datatype. Then in the Parse method  it will inspect if the value is either 0 or 1, if not it will convert the value to a real boolean.

  1: public class BooleanFieldAdapter : IFieldAdapter
  2: {
  3:     /// <summary>
  4:     /// Contains the GUID of the true/false datatype we want to parse using this FieldAdapter
  5:     /// </summary>
  6:     /// <value></value>
  7:     public Guid DataTypeId
  8:     {
  9:         get { return new Guid("38b352c1-e9f8-4fd8-9324-9a2eab06d97a"); }
 10:     }
 11: 
 12:     /// <summary>
 13:     /// Parse the data
 14:     /// </summary>
 15:     /// <param name="value">The value to parse</param>
 16:     /// <param name="fieldAdapterService">The field adapter service.</param>
 17:     /// <returns></returns>
 18:     public object Parse(object value, Property property, FieldAdapterOptions fieldAdapterService)
 19:     {
 20:         if (!(value.Equals("0") || value.Equals("1")))
 21:         {
 22:             // Parse boolean value and return result
 23:             bool boolValue = false;
 24:             bool.TryParse(value.ToString(), out boolValue);
 25:             
 26:             return boolValue;
 27:             
 28:         }
 29:         return value;
 30:     }
 31: }

This mechanism is very powerful. In fact the whole media import is based on this. Currently it only support a few default Umbraco Datatypes. For later versions I will make sure that FieldAdapters will fix import issues for all popular third party datatypes, like Ucomponents also. If you don’t want to wait for that use the API to create your own FieldAdapter and include it in your package.

Improved API

In 1.0 you could extend CMSImport. but extension points existed in different assemblies. With version 1.1 all extension points exist in the CMSImport.Extensions.DLL. Using this assembly you can create your own DataAdapters and FieldAdapters and you can use the event system. In chapter 8 of the manual you can read all about this. I’ve also created a sample project that you can use as a start. This contains samples from how to create a DataType to how to support Structured Import using the Event System. This was written for CMSImport PRO but you can use it for CMSIMport also, although not all samples will work. The sample code uses the AdventureWorks database a  DataSource. You can download this database from  CodePlex and you can download the Samples from the CMSImport site.

Small other changes

This following other small changes are included in this release.

New version of the CSV Parser

In the 1.0 release I was using an older version of the this Csv Parser. This one is upgraded  to the newest release an didn’t have any issues with it.

Better Error Handling for Saved Imports

When you deleted the root folder in CMSImport PRO 1.0. The only message that you would get was “Object reference not set to an instance of an object” and you could start all over again. In the current version CMSImport will report what is wrong and allows you to fix those issues.

InvalidImportOptions

Now with documentation

The whole import process and API is documented now. You can download the manual from the CMSImport site.

Delete failed import documents that were created during import

When a new document is created during the import process and the import process fails the document will be deleted instead of left in the tree.

Improved performance by not setting null values

When a value contains null it will not be mapped against the Document property. This will save a few database calls according to this blogpost. This is only for new imported  documents. When a document is being updated the null value could be the new value and therefore will be assigned to the property.

What’s next

The coming 1.2 version will include more FieldAdapters and support for third party Datatypes. This will be included in both the Free and Pro edition of CMSImport.. I hope to have this ready by the end of this year. I’m also working on version 2.0 that will support structured import out of the box. This will be released early next year. Structured Import will only be included in the PRO edition.

Get it while its hot

Download the free version from our.umbraco.org. Please vote up the package if you like it. Or buy a Pro license from the CMSImport website.

Comments [0] | | #