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

# Wednesday, 21 August 2013
Wednesday, 21 August 2013 11:11:52 (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 PRO always had support for uBlogsy. When testing the latest version of uBlogsy I found that it was completely different from the V2 version. The latest version of CMSImport PRO (2.4 and above) support version 3 also. The version 2 version of uBlogsy was easier to use from an Import point of view. Most relations to authors etc were stored as comma separated values. This is changed to MNTP now. So thanks to uBlogsy, CMSImport supports lookups for MNTP now :). But as mentioned above there are a few steps you need to do to import content in uBlogsy, so in this blog post I try to explain the process form importing all data from a Wordpress file (thanks Morten for sending me one).

Setup

First we need to install uBlogsy V3 and CMSImport. In this post I’ll be importing the comments also, therefore I need to install uCommentsy (the new commenting system for uBlogsy that is not in out of the box)also. From version 2.4 of CMSImport not all Data Adapters are included in the core package anymore, this is to avoid a large list of available adapters that most people don’t use. So to import Wordpress data we need to install the additional CMSImport.DataAdapters.Wordpress package also. Before starting CMSImport make sure you have your license file in the bin folder of your Umbraco installation also.

uBlogsy is using MNTP for assigning authors and Labels (Categories in Wordpress). The XPath configuration gave me some issues when using uBlogsy. It couldn’t find the rootnode when editing posts.  By default the xPath configuration is searching from the current node as you can see in the image below.

xpath

This might be ideal when you run multiple blogs with multiple authors and labels but for my situation selecting all authors and categories works fine and is then always available in the post. To change the xpath configuration open the following datatypes and update the xpath.

DataType XPath expression
[uBlogsy] [MNTP] Author Picker //uBlogsyContainerAuthor
[uBlogsy] [MNTP] Label Picker //uBlogsyContainerLabel

Before importing the posts we first need to import author, categories and tags data. CMSImport can use this data for lookup values and assign the values during the import of Blog posts.

Import meta information

CMSImport will automatically assign meta information such as Author, Labels (Categories in Wordpress) and  Tags. This will be based on a lookup value, when CMSImport can find the related node it will assign it to the Blog post otherwise it will be ignored. So the first thing we need to do is import the meta information. When you open CMSImport and select import data you should use the following data adapters to import the meta information:

Data adapter  
Wordpress Authors Imports authors from a Wordpress export file
Wordpress Categories Imports the labels from a Wordpress export file
Wordpress Tags Imports the tags from a Wordpress export file

When you hit next for any of the above Data Adapters you need to select a location. Below the example for authors, tags and labels work the same. You will also see that the document type is automatically assigned. This is because CMSImport knows that uBlogsy is installed. Also the mapping is automatically assigned correctly. So after assigning the location you can hit next a few times and the Meta information will be imported.

author

Importing blog posts

Ok we are coming to the real task, importing the blog posts. This the same as importing the meta information. First you select Wordpress blog posts as the datasource. Then select Blog as the root to import the data. uBlogsy will automatically create the date folders  when you are importing. Also the mapping is created automatically. When you import the data the meta information will be assigned automatically. After importing the data save the Import definition, we need it again when importing the comments. After the import definition the  post info tab of a blog post  should look similar as the image below. Author, tags and label info is assigned automatically.

postinfo

Importing comments

The last step is importing comments. This is a bit different from importing the above information. To import the comments, open the CMSImport saved imports tree for content. Right click on the saved import definition for posts and select Create child definition and select Wordpress comments as the data source. You don’t need to pick a location on the next step. CMSImport will find the location based on the imported posts. All other steps are exactly the same as importing the other data.

childimport

Once the data is imported your tree should look something like this.

tree

That’s it

That’s all you need to do to import Blog posts and comments from a Wordpress site into uBlogsy 3 for Umbraco. If your Wordpress file contains pages also you can use the Wordpress page data adapter to import the page data as well.  This article can also be used if you have BlogML data, replace Wordpress with BlogML adapters and all should work.

Happy importing!

Comments [0] | | # 
# Thursday, 14 February 2013
Thursday, 14 February 2013 10:29:23 (GMT Standard Time, UTC+00:00) ( SEO Checker | Umbraco )

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

It took a few months of development but I’m glad to finally announce SEO checker V1! If you haven’t done already you can read previous blogposts about this package or watch the screencasts about SEO checker. I think it’s a package every site should have installed, when building sites for clients. I have followed the #umbraco tag on twitter for more than a year and have seen most sites that are released contain SEO issues.  When those sites had SEO Checker installed it would have warned you before putting the site live. So I hope you will at least download SEO checker and check you sites on localhost before putting it live.

Using SEO Checker for content editors

There is one big feature the previous blogposts didn’t cover and that is using SEO Checker for content editors.SEO Checker comes with a Data Type that can be added to document types. The SEO Checker Data Type will show a Snippet preview how the page will be shown  in the Google search results. If you are using a relevant  Title and Meta Description Google will use these in the search results. Therefore these elements are important.

seochecker-contenteditor
It’s possible to specify a focus keyword, this is the keyword you want to rank the page for, use the Keyword tool icon to get help selecting the keywords you want to rank the page for.  SEO Checker will validate if the keyword can be found in the most important elements of the page:

  • Page Title (H1)
  • Url
  • SEO Title (<title>)
  • SEO  Description (<meta name="description"…..)
  • At least once more in the text of the page

You can also specify the SEO Title, SEO Description and SEO keywords (when configured). The page will also be checked for other SEO Issues on the page.  See the documentation for a list of all validations.
The unpublished version of the page will be checked, this allows you to solve issues before publishing the page!

Configuration of the Data type

By default the SEO Checker data type will show a field for SEO title and description. If you already have those properties on your document type you can use configuration of the document type to map those .

image

1.    Map SEO title against the existing SEO title property
2.    Map SEO keywords against the existing SEO keywords property
3.    Map SEO description against the existing SEO description property
4.    Use the keywords meta tag (Google and all major search engines ignore this meta tag).

Document type meta data configuration

Using default SEO Properties you can specify default values  for SEO Title and SEO description. When the page is missing the SEO title or description info these mapped properties will be used.  The title will be copied. The description will take the first paragraph from the mapped property. This ensures you always have you meta tags filled. The validation process will validate if the tags are matching length criteria.

Title template

It’s also possible to specify a template for the SEO Title. This template will be used to render the <title> tag in snippet preview and on the page.The template can contain fixed text and placeholders, placeholders have the same syntax as you would use in Umbraco Macro’s:

  • [#Property alias ] will get the property from the current document
  • [$property alias] recursive look up the property

The following fixed properties can be used in the template:

  • @nodeName contains the name of the page
  • @seoTitle contains the value of the SEO title property

When using the above template configuration the <title> tag will be rendered as:

<title>Simple website | Simple website &#169; 2013</title>

Use Metadata inside your template

SEO Checker comes with a small library to render Meta Tags in HTML. This is only necessary when you use the SEO Checker data type. You can use the library in Razor, XSLT and usercontrol macro’s. The library can be used in both MVC and Masterpage mode. To render the metatags for the current page in razor simply use:

This will render all metatags for the page like this:

<title>Using Modules | SEO Checker</title>
<meta name="description" content="Umbraco modules encapsulate specific bits of advanced functionality that are easily added to your website." />
<meta name="robots" content="index, follow" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Download V1 Trial

What are you waiting for. download SEO Checker and have a play on your local machine!

Comments [0] | | # 
# Monday, 04 February 2013
Monday, 04 February 2013 13:32:47 (GMT Standard Time, UTC+00:00) ( SEO Checker | Umbraco )

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

The RC is already removed from the version info, a release is around the corner! A perfect time to talk about validating pages using SEO Checker. To validate a site, or a portion of a site for SEO issues, open SEO Checker and select the Validate Pages option from the menu. This will show the following screen. By default the root is selected, if you want to validate a portion of a site specify the start location. When the include children is checked all published children will be validated also. When you hit start the pages will be added to the validation queue.

 validate pages

Besides this manual process, pages will be added to the validation queue when they are published also. Only published pages having a template assigned will be validated!

Validation queue

Pages will not be validated immediately, instead they will be added to the validation queue. Validation occurs on the background so you will not have to wait until the validation process is finished. When all pages are validated the result will be available in the Validation issues overview.

validationqueue-small

Validation issues

This overview will show all issues found when validating the page. The documentation will contain a full list of validation when it’s released. When an issue contains the description “Template issue” it means that the issue is found in the template. A template issue is only reported once for every template instead of reported on every document that uses the template.

ValidationIssues-markedwithoptions

Options:

  1. When selected warnings will included in the overview.
  2. When selected errors will included in the overview.
  3. When a period is selected solved items since the selected period are also displayed in the overview. Solved issues are displayed in strikethrough. In the example above the metadata issues are solved.
  4. Opens the document in a popup
  5. Opens the template assigned to the document in a popup. This option will only be available for Users that have access
  6. Deletes the issue from the overview, or adds the item to the ignore list.

Delete and ignore issues

Using the delete button in the various overviews you can delete an issue from the overview. This will show the following dialog.

deleteissuedialog

When you hit “delete” it will just remove the item from the overview. Next time validation occurs the issue will be reported again. When you check the “Ignore this issue next time” checkbox the item will be added to the ignore list and the issue will not be reported again next time validation occurs. Use the Ignore list overviews to see which items are ignored.

Download

Want to try SEO Checker today? Download the release candidate.

Non production Warning:
This is a  release candidate!! SEO checker is tested on different sites but can still have some issues in specific situations. We love to get some feedback but don't use this package in production yet! If you find any issues please send us an email support@soetemansoftware.nl and we will get back to you ASAP!  Also keep an eye on our hotfix location! Here you find the most recent bugfixes.  The release candidate will expire on May 1th 2013. After May 1th it will fall back to trial mode which means it will only work on localhost and you can only validate one page at a time.

Comments [0] | | # 
# Tuesday, 22 January 2013
Tuesday, 22 January 2013 20:58:32 (GMT Standard Time, UTC+00:00) ( Package | SEO Checker | Umbraco )

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

After releasing the beta version of SEO Checker almost two months ago, it’s time for a release candidate. An exciting time because if all goes well we have the final release available in just a few weeks(it’s all about writing the user manual ;-) ). The release candidate solves the following issues found in the beta version:

  • Fixed encoding issues in the validation process
  • Added a validator to prevent robots.txt, or meta follow/index  is blocking the whole site being crawled
  • If a robots.txt file exist on disk, use that one instead of generating a dynamic one
  • Fixed several issues regarding  url rewriting
  • Fixed several issues regarding broken inbound links
  • Changed low level error messages to user friendly ones when an exception occurs
  • Added several improvements in configuration
  • Fixed Umbraco V6 RC compatibility issues

If you already installed SEO Checker beta it’s best to upgrade since the beta expires February 1th and upgrading is easy, just use the package installer. So what are you waiting for….download the RC today

Non production Warning:
This is a  release candidate!! SEO checker is tested on different sites but can still have some issues in specific situations. We love to get some feedback but don't use this package in production! If you find any issues please send us an email support@soetemansoftware.nl and we will get back to you ASAP!  Also keep an eye on our hotfix location! Here you find the most recent bugfixes.  The release candidate will expire on May 1th 2013. After May 1th it will fall back to trial mode which means it will only work on localhost and you can only validate one page at a time.

Comments [0] | | # 
# Wednesday, 16 January 2013
Wednesday, 16 January 2013 09:51:44 (GMT Standard Time, UTC+00:00) ( Package | SEO Checker | Umbraco )

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

A couple of weeks ago I blogged about SEO Checker. With the first release candidate and final release around the corner it’s time to highlight some features. Today I want to talk about fixing Inbound Links.We all had this experience, searching for information and found a page in Google and when we hit that link we get a 404 page, friendly message or not it’s not the best experience and Google doesn’t like this either.

In the example below I’m using the basic starter kit that comes with Umbraco and visit the page gofurther.aspx. the 404 page will be shown, but SEO Checker will also log the url.  When you open the  Inbound link error page in SEO Checker you will see that gofurther.aspx is reported as broken. Using the content picker you can select the page you want to redirect to. Next time someone is visiting the gofurther.aspx the request is redirected to the selected page.

 InboundLinkErrors  

Handling different extensions

If you migrate a site from php environment you can setup the same structure in your umbraco site. Let’s say the previous php site had this structure:

  • mytestsite.com/
    • mytestsite.com/installing-modules.php
    • mytestsite.com/go-further.php
    • mytestsite.com/getting-started.php

Our new Umbraco site is using aspx extensions (or no extensions at all), so when we try to access the installing-modules.php page, the visitor will see a 404 page.  If you have SEO Checker installed it will make sure the installing-modules.php page will be redirected to the installing-modules.aspx page.

This means search results from Google will still work (and get updated to the new page because of the 301 redirect) and all links to the php version of your site will still work.

When the page cannot be found at all the url will be logged and we can map the correct url on the Inbound Links page as described in the previous scenario.

Handling structure changes

When you rename or move a document in Umbraco the structure will change. For example when we change the Installing modules page to Installing Umbraco modules. The url changes from installing-modules.aspx to installing-umbraco-modules.aspx. The result will be that when people are visiting the old installing-modules.aspx  url, they will see a 404 instead of the Page. SEO Checker will keep track of changes in the url structure and will redirect the old installing-modules.aspx  url to the new installing-umbraco-modules.aspx url.

If you are only interested in this scenario you might want to check out the free 301 Url Tracker package.

Comments [0] | | # 
# Friday, 30 November 2012
Friday, 30 November 2012 09:24:41 (GMT Standard Time, UTC+00:00) ( Package | SEO Checker | Umbraco )

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

 
For those of you following me on twitter probably know I’ve been working on a new package, SEO checker for the last few months(thinking about it for a few years). Today it’s time to finally release the first beta version of this package and this is the first blog post giving you an overview of most possibilities. The next blog posts will cover more detailed information about a certain feature.

SEO Checker is build to optimize your Umbraco Site SEO! It will help you find common SEO issues on the website, help you pages rank better for a certain keyword by making sure that keyword is found on the necessary HTML elements. It comes from the idea that most Umbraco websites have SEO Issues, missing meta tags, canonical url’s , broken links, test content, inline scripting, huge viewstate (my favorite ;-)) etc. When you install SEO Checker you will find a new section where you can validate pages, find inbound link errors and find configuration errors.

I’ve recorded a few screencasts that demo the functionality, check them out. I would love to have feedback so please read further, watch the screencasts,  install the package and let me know what you think.

Validate pages

SEO checker allows you to validate a complete  site, or portions of a site. Simply select validate pages from the menu, select a root node and hit start, as you can see in the image below. 
Validation happens on a background thread, you can validate 1000 pages without having to wait for the results before leaving the page. Instead pages are added to the validation queue first.

image

When you publish a page it will automatically being added to the validation queue by default.

Once the validation queue is empty you can open the validation issues page which gives you an overview of all validation issues for a given page or template. All validations are (somehow) based on the Search Engine Optimization Starter Guide document from Google , so it’s based on facts and not on opinions from SEO consultants. You can filter the overview by errors and  warnings.It’s also possible to show resolved issues since a given date. The image below shows you the url to simplesite.com is resolved and shows you a few open issues. You can edit the page, or template directly from this overview. It’s also possible to delete the item from the overview. When you delete the item you can select the option to always ignore the issue during validation.

image

 

SEO checker datatype

SEO checker allows you to preview the Google search result snippet using the SEO checker datatype when editing content  and will give feedback about keyword usage in content and meta information. The same datatype will report validation issues based on the unpublished version of the document. This allows you to fix all issues before publishing the page to your website. In the image below you’ll see that we want to rank the page for Umbraco Modules.  If the keyword is not found in a certain tag, this will be reported as a validation issue.

image

SEO checker will look for the focus keyword in the following tags:

  • Title
  • Meta description
  • H1
  • Body
  • Url of the page

SEO checker will also report any other content related issue it found on the page. In this case it found the broken link htp://www.umbraco.com. SEO checker knows this must be http://www.umbraco.com/ and suggest you will use http:// instead of htp:// in the error description.

Fix and avoid Inbound link issues

SEO checker will report any inbound link that is broken. To fix a broken link you select the page you want to redirect to and the next time a user is browsing to the broken link the user will be redirected to that selected page. In the example below the user requested installin-modulezz.aspx. This was reported as broken. and is now pointing to the installing modules page. So the next time a user is requesting the installin-modulezz.aspx the request will be redirected to installing-modules.aspx.

image

Seo checker will avoid broken links by redirecting  url’s with the wrong extension to the correct one. So if a user is requesting http://www.somesite.nl/modules.php the request will be redirected to http://www.somesite.nl/modules.aspx. When you rename or move a document inside Umbraco SEO checker will makes sure every request for the old url is redirected to the new url.

Dynamic robots.txt and sitemap.xml

SEO checker allows you to generate a dynamic Robots.txt and Sitemap.xml files. This will make sure search engines don’t index Umbraco system folders and allows you to submit an xml sitemap to Google. You can specify settings for the xml sitemap per document type, so if you want to exclude a certain document type or change the priority it’s possible with a few clicks.

image 

URL Rewriting

You want to make sure every page can be accessed by one url. If a url can be accessed with and without www. prefix for example, search engines treat those url’s as unique and it can cost you page rank. When I was building SEO checker I had some issues with URL rewriting by editing the XML configuration files. To make it easier for you SEO checker comes with a built-in URL rewriting module that you can configure with a few mouse clicks (only one if you are not using directory url’s). 

image

Requirements

SEO checker requires:

  • IIS7
  • Umbraco Version 4.8 and up.
  • One of the following database SQL Server 2005/2008 (Express), SQL CE 4 and Mysql
  • modify rights to folders: /bin, /umbraco, and /app_data folder

Commercial package

Once the beta is over SEO checker will be a commercial package.Prices will be the same as the CMSImport  package:

  • € 99,00  for a domain license
  • € 299,00 for a server license
  • € 499,00 unlimited license

Download

Update 1/22/2012 : SEO Checker Release candidate is available

Download the beta version of SEO checker today.

BETA Warning:
This is a Beta release!! SEO checker is tested on different sites but can still have some issues in specific situations. We love to get some feedback but don't use this package in production! If you find any issues please send us an email support@soetemansoftware.nl and we will get back to you ASAP!  This beta version will expire on Feb 1 2013.

Also keep an eye on our hotfix location! Here you find the most recent bugfixes.

Comments [1] | | # 
# Tuesday, 25 September 2012
Tuesday, 25 September 2012 09:36:02 (GMT Daylight Time, UTC+01:00) ( Package | Umbraco )

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

A couple of months ago, Umbraco V4.8 was released and when I was testing CMSImport against this version I got a weird exception.

dllerror

What happened?

I’m using the HTMLAgilityPack to extract images and files from the bodytext property so we can import them into Umbraco. In previous versions, Umbraco shipped with the 1.3.0 version. The version of the HTMLAgilityPack that is shipped in 4.8+ is version 1.4.5.0. Since the dll is signed it’s throwing an error in case of a version conflict. I’ve seen a post on the forum where Lee Kelleher describes a similar issue. In the case of UComponents it’s the Lucene DLL but it’s the same problem as I was facing. To fix this issue as described in the forum thread requires an entry in the web.config file and putting the Legacy DLL into a separate folder. It’s all fine to use upgrade instructions for a client project but when you develop a package you don’t want your customers manual upgrade web.config files for a specific version. You also don’t want to have a big if statement in your installer that creates entries based on a version number and you also don’t want to drop support for older versions of Umbraco because of this minor conflict.

The solution

After searching a bit, I found this interesting article that describes the AppDomain.AssemblyResolve Event. This event gets triggered when an Assembly is required that can’t be found and allows you to return the correct assembly. In our case the DLL Version 1.3.0.0 of HTMLAgilityPack. In the example below you see that I derive my class from ApplicationBase (I know there is a new class in 4.8, but I’m still supporting 4.7 also ;-)) so this class will be picked up automatically . When the  required assembly (Args.Name on line 13) is the HTMLAgilityPack Version 1.3.0 I load that assembly from the /bin/legacy/ location and all is working again :) 

Update 2-10-2012 Modified source code. It doesn’t use HTTPContext anymore since that might not be available

   1:      public class UpdateThirdPartyDllBindings : ApplicationBase
   2:      {
   3:          public UpdateThirdPartyDllBindings()
   4:          {
   5:              AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
   6:          }
   7:   
   8:          /// <summary>
   9:          /// Assembly could not be resolved let's see if we can load it dynamically
  10:          /// </summary>
  11:          Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
  12:          {
  13:              if (args.Name == "HtmlAgilityPack, Version=1.3.0.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a")
  14:              {
  15:                  try
  16:                  {
  17:                      //Get the bin folder. Don't use HTTPContext since that can be null
  18:                      string binFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin\\legacy");
  19:                      string legacyFile = Path.Combine(binFolder, "HtmlAgilityPack.dll");
  20:                      return Assembly.LoadFile(legacyFile);
  21:   
  22:                  }
  23:                  catch (Exception ex)
  24:                  {
  25:                      Log.Add(LogTypes.Error, -1, string.Format("SEOChecker error loading HTMLAgilityPack version {0}:{1} ", args.Name, ex));
  26:                  }
  27:              }
  28:              return null;
  29:          }
  30:      }

All I need to do now is make sure the Legacy DLL is shipped in the package. When you are using an older version of Umbraco this Legacy DLL will exists in your bin folder but will be ignored and for version 4.8 + the AssemblyResolve implementation will make sure the legacy DLL is loaded.

Hope this helps you solve version conflicts of dll’s in your own packages

Comments [0] | | # 
# Tuesday, 20 December 2011
Tuesday, 20 December 2011 13:57:00 (GMT Standard Time, UTC+00:00) ( MemberExport | Package | Umbraco )

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

I’ve just released MemberExport 2.0. Apart from another awesome logo by Arnold Visser.I’ve added some functionality as well.

memberexport100x100

Native Excel export

MemberExport 1.x could only export to a csv file. This is great for most of us but when you select a wrong separator and want to open the csv file in Excel directly it will probably looks a bit messy like the example below.

wrongformat

MemberExport 2.0 Pro let’s you select the export option csv or Excel file. When you select Excel file it will export the data to an Excel file instead of csv and all the data is formatted correctly.

image

Export provider

I don’t like closed systems, all of my packages are open for extension. When creating the Excel export option I wanted the export option to be a provider model. Not only to make this task easier for myself but also so you can use MemberExport to connect to your custom ERP system. Implementing an export provider is pretty straight forward. The example below is the implementation of the CSV Provider.

CSVProviderUI

The CSVProviderUI class is the class which is responsible for the UI part of the provider. Add a reference to the MemberExport.Library dll and derive from ExportProviderUIBase class. Implement to following methods:

  • OnInit, create the UI controls
  • Initialize, initialize the UI options based on the stored export provider settings. In this case exportProvider will hold the text delimiter and text indicator options.
  • GetOptions will return the export provider settings so we use those settings when exporting records
  • The name property will return the name of the provider stored in the Export as dropdownlist when selecting an export provider.
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using MemberExport.Resources.Helpers;
using umbraco.uicontrols;
 
namespace MemberExport.Library.ExportProviders.CSV
{
    /// <summary>
    /// Renders the Layout for the CSV Provider
    /// </summary>
    public class CSVProviderUI : ExportProviderUIBase, INamingContainer
    {
        protected DropDownList _csvTextIndicatorDropDownList = new DropDownList();
        protected DropDownList _csvSVSeperatorDropDownList = new DropDownList();
 
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
 
            _csvSVSeperatorDropDownList.Items.Add(new ListItem(";", ";"));
            _csvSVSeperatorDropDownList.Items.Add(new ListItem(",", ","));
 
            _csvTextIndicatorDropDownList.Items.Add(new ListItem(ResourceHelper.Current.GetStringResource("CSVNoTextIndicator"), ""));
            _csvTextIndicatorDropDownList.Items.Add(new ListItem("\"", "\""));
            _csvTextIndicatorDropDownList.Items.Add(new ListItem("\'", "\'"));
 
            PropertyPanel delimiterPropery = new PropertyPanel();
            delimiterPropery.Text = ResourceHelper.Current.GetStringResource("CSVSeperatorProperty");
            delimiterPropery.Controls.Add(_csvSVSeperatorDropDownList);
 
            PropertyPanel stringIndicatorPropery = new PropertyPanel();
            stringIndicatorPropery.Text = ResourceHelper.Current.GetStringResource("CSVTextIndicatorProperty");
            stringIndicatorPropery.Controls.Add(_csvTextIndicatorDropDownList);
 
            Controls.Add(delimiterPropery);
            Controls.Add(stringIndicatorPropery);
        }
 
        /// <summary>
        /// Sets the export options (delimiter and string indicator).
        /// </summary>
        /// <param name="exportProvider">The export provider.</param>
        public override void Initialize(ExportProviderBase exportProvider)
        {
            CSVProvider csvProvider = exportProvider as CSVProvider;
            if (csvProvider != null)
            {
                _csvSVSeperatorDropDownList.SelectedValue = csvProvider.Delimiter;
                _csvTextIndicatorDropDownList.SelectedValue = csvProvider.StringIndicator;
            }
        }
 
        /// <summary>
        /// Returns the selected export options (delimiter and string indicator).
        /// </summary>
        /// <returns></returns>
        public override ExportProviderBase GetOptions()
        {
            CSVProvider csvProvider = new CSVProvider();
            csvProvider.Delimiter = _csvSVSeperatorDropDownList.SelectedValue;
            csvProvider.StringIndicator = _csvTextIndicatorDropDownList.SelectedValue;
            return csvProvider;
        }
 
        /// <summary>
        /// Return the name of the provider. this will be displayed in the selectbox
        /// </summary>
        /// <value>The selected name.</value>
        public override string Name
        {
            get { return "CSV file"; }
        }
    }
}

CsvProvider

The second part we need implement is the provider itself which handles the actual export process. Create a new class and derive from ExportProviderBase.  This will give the following methods/properties:

  • Export, responsible for the export process
  • Icon, will be displayed when opening the saved exports tree

In this implementation we’ve added the StringIndicator and Delimiter options, which gets set from the UI. The export method will give a list of columns to export and all records using an IRecordReader.  The rest of the code is implementation specific. Two important things to know when exporting records.  When assigning a value always use the ValueParser factory

ValueParser.Parse(reader.GetObject(column.Alias), column));

To write the file to the browser either use the WriteResponseString (for stringvalues ) or WriteResponseBytes (for a byte array) methods. Both methods need the Contenttype (Mimetype) and fileExtension, in this case csv.

using System;
using System.Collections.Generic;
using MemberExport.Library.Csv;
using MemberExport.Library.Members;
using MemberExport.Library.Types;
 
namespace MemberExport.Library.ExportProviders.CSV
{
    /// <summary>
    /// CSV (Default) implementation of MemberExport
    /// </summary>
    [Serializable()]
    public class CSVProvider : ExportProviderBase
    {
        /// <summary>
        /// Exports the data to a csv file
        /// </summary>
        /// <param name="columns">Collection of column info</param>
        /// <param name="reader">The actual data to export</param>
        public override void Export(List<Types.MemberField> columns, umbraco.DataLayer.IRecordsReader reader)
        {
            //Use a csv writer object
            CsvWriter writer = new CsvWriter(Delimiter, StringIndicator);
 
            //Add columns to export
            foreach (MemberField field in columns)
            {
                writer.Columns.Add(field.Text);
            }
 
            //Add data to export
            while (reader.Read())
            {
                //Get values for the current row
                List<object> values = new List<object>();
                foreach (MemberField column in columns)
                {
                    values.Add(ValueParser.Parse(reader.GetObject(column.Alias), column));
                }
 
                //write values to csvwriter;
                writer.Add(values.ToArray());
            }
            //Write response to the browser
            WriteResponseString(writer.Parse(), "application/excel", "csv");
        }
 
        /// <summary>
        /// Gets or sets the string indicator.
        /// </summary>
        /// <value>The string indicator.</value>
        public string StringIndicator { get; set; }
 
        /// <summary>
        /// Gets or sets the delimiter.
        /// </summary>
        /// <value>The delimiter.</value>
        public string Delimiter { get; set; }
 
        /// <summary>
        /// Returns the icon that will be displayed in the saved tree
        /// </summary>
        /// <value>The icon.</value>
        public override string Icon
        {
            get
            {
                return "csvexport.gif";
            }
        }
    }
}

That’s all, compile and add to the bin folder of your Umbraco install and you can use the provider!

ValueParsers

By default MemberExport exports the stored value from  the database. When this value is an Id value you might want to export the text value instead. This can be achieved using a value parser. By default MemberExport comes with value parsers for the following datatypes :

  • Checkbox
  • Dropdownlist
  • MNTP
  • MuiltipleDropdownlist
  • Radiobox
  • Ultimatepicker

In the example below we will write a value parser for the True/false datatype. By default values will be exported as 1/0. We want the values to be exported as yes/no for this example.

Before you ask, this isn’t in the core because some people want 0/1, some true/false, some yes/no etc.

First we need to add a reference to the MemberExport.Library dll. Then we can create a class that implements the IValueParser interface

  public class TrueFalseParser : IValueParser
    {
        /// <summary>
        /// Returns the Datatype GUID of the true/false Render Control.
        /// </summary>
        public Guid DataTypeId
        {
            get { return new Guid("38b352c1-e9f8-4fd8-9324-9a2eab06d97a"); }
        }
 
        /// <summary>
        /// Converts the 0/1 to a normal yes/no string.
        /// </summary>
        /// <param name="memberfieldInfo">The memberfield info.</param>
        /// <param name="value">The value.</param>
        /// <returns>The yes/no string</returns>
        public object Parse(Library.Types.MemberField memberfieldInfo, object value)
        {
            return string.Format("{0}", value) == "1" ? "yes" : "no";
        }
    }

The DataTypeId property needs to return the GUID which is displayed on the datatype edit screen.

image

The Parse method will be called when a true/false property value is exported. In the above example we transform the value to yes/no.
The following information about the exported field is available in the memberFieldInfo variable:

  • DataTypeId. The GUID which is displayed on the datatype edit screen
  • DatatypeNodeId. The node id  of the Datatype.
  • Alias. The Property alias.
  • Text. The Property text.

To use the Value Parser all we need to compile the project and add the dll to the bin folder of the Umbraco install. Then it will be picked up automatically and values will be exported as yes/no. In the example below the Active column is exported as true/false value using the Value Parser.

image

Download and install

You can download the MemberExport package from the Umbraco Deli. Just install the package, also when you want to update your current version. When you are a Pro user make sure the license file is still in your bin folder to unlock the Pro features.

Happy exporting!

Comments [0] | | # 
# 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] | | #