development · module

Pre-population Item Version module for Sitecore development

Someone wants you to develop a simple Sitecore module which supports to pre-populate Sitecore item versions so that he doesn’t have to enter bulk of data fields manually when a very first language version of a specific site is created (that guy is so lazy and so am I :D)

Assumptions:

  • the sites have >= 2 languages
  • the module copies all fields’ value from the source language version then pastes them to appropriate fields of the target language version while it’s being created (excluding system fields, shared fields)
  • there is a way to configure the source language version of a specific site
  • if there is NO source language version of a specific site, the module will use the global default source language which is configurable
  • if the global default source language is NOT available (due to wrong configuration), the module will use the default language of every single site as the global default source language (the fallback)
  • in terms of technical approach, would create a custom event handler and would add it to item:versionAdded event (item new version was added to), the reference

If that is the case, you may try to play with my Pre-population Item Version module.

How to install it

Download this module on Sitecore Marketplace or on Gitlab as a Sitecore package then install it to your Sitecore instance via Installation Wizard

How to use it

  1. open App_Config\Include\z.Vhs.PrePopulationItemVersion.config
    • piv_2
  2. correct Vhs.PrePopulationItemVersion.SiteList by adding your sites info (separator is “|” pipe character), the site info’s formats:
    • {site name} -> it means using global source language
    • {site name}:{language iso code} -> it means using the specific source language instead of the global source language (separator is “:” colon character)
    • piv_1
  3. update Vhs.PrePopulationItemVersion.DefaultSourceLanguage if you want to change the global source language (the default one is “en”)
    • piv_3
  4. log into Sitecore, open Content Editor and play around with the module to make sure it works properly
    • in this case, we will play with site1:zh-HK
      • site name: site1
      • source language: zh-HK (language iso code)
    • switch to source language item version (Cantonese) then enter some sample data and save it
      • piv_4
    • switch to target language item version (English) then click on Add a new version link
      • piv_5
    • you would see an English language item version is created whose fields’ value is copied from source language item version (Cantonese)
      • piv_6

Not Good Enough? Please feel free to download the source code and add your own enhancements if necessary.

Got issues?

Please send your issues (with screenshots if possible) to viet.hoang.sitecore@gmail.com so that I have a chance to understand your problem and be able to suggest the solution.

Happy Sitecore coding!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s