<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>language &#8211; blog.boro2g .co.uk</title>
	<atom:link href="https://blog.boro2g.co.uk/tag/language/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.boro2g.co.uk</link>
	<description>Some ideas about coding, dev and all things online.</description>
	<lastBuildDate>Fri, 17 Jun 2011 13:06:27 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.5.8</generator>
	<item>
		<title>Create a version of an item in all languages in the Sitecore client</title>
		<link>https://blog.boro2g.co.uk/create-a-version-of-an-item-in-all-languages-in-the-sitecore-client/</link>
					<comments>https://blog.boro2g.co.uk/create-a-version-of-an-item-in-all-languages-in-the-sitecore-client/#respond</comments>
		
		<dc:creator><![CDATA[boro]]></dc:creator>
		<pubDate>Fri, 17 Jun 2011 12:46:21 +0000</pubDate>
				<category><![CDATA[Sitecore]]></category>
		<category><![CDATA[command]]></category>
		<category><![CDATA[language]]></category>
		<category><![CDATA[sitecore]]></category>
		<guid isPermaLink="false">http://blog.boro2g.co.uk/?p=88</guid>

					<description><![CDATA[<p>This post aims to demonstrate how to add new versions for all languages if they dont exist in the cms. When you click buttons within the Sitecore client, typically Sitecore commands are used to map these actions to c# code. This link is defined in /App_Config/Commands.config. Some sample entries here are: [crayon-69b255cf5650b241193726/] If you want [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.boro2g.co.uk/create-a-version-of-an-item-in-all-languages-in-the-sitecore-client/">Create a version of an item in all languages in the Sitecore client</a> appeared first on <a rel="nofollow" href="https://blog.boro2g.co.uk">blog.boro2g .co.uk</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This post aims to demonstrate how to add new versions for all languages if they dont exist in the cms.</p>
<p>When you click buttons within the Sitecore client, typically Sitecore commands are used to map these actions to c# code. This link is defined in /App_Config/Commands.config. Some sample entries here are:</p><pre class="crayon-plain-tag">&amp;lt;command name=&quot;item:addversion&quot; type=&quot;Sitecore.Shell.Framework.Commands.AddVersion,Sitecore.Kernel&quot; /&amp;gt;
&amp;lt;command name=&quot;item:archive&quot; type=&quot;Sitecore.Shell.Framework.Commands.Archive,Sitecore.Kernel&quot; /&amp;gt;</pre><p>If you want to add your own commands you can either edit this file or setup a patch file in /App_Config/Include. Note the patch file is the preferable option.</p>
<p>The code used for this example is:</p><pre class="crayon-plain-tag">using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using Sitecore;
using Sitecore.Data.Items;
using Sitecore.Data.Managers;
using Sitecore.Diagnostics;
using Sitecore.Globalization;
using Sitecore.Shell.Framework.Commands;
using Sitecore.Web.UI.Sheer;

namespace ###.Domain.Cms.Specialization.Shell.Framework.Commands
{
    /// &amp;lt;summary&amp;gt;
    /// Create a version of the current item in all languages
    /// &amp;lt;/summary&amp;gt;
    public class CreateVersionInAllLanguages : Command
    {
        public override void Execute(CommandContext context)
        {
            Assert.ArgumentNotNull(context, &quot;context&quot;);

            if (context.Items.Length == 1)
            {
                NameValueCollection parameters = new NameValueCollection();

                parameters[&quot;items&quot;] = base.SerializeItems(context.Items);

                Context.ClientPage.Start(this, &quot;Run&quot;, parameters);
            }
        }

        protected void Run(ClientPipelineArgs args)
        {
            Item item = base.DeserializeItems(args.Parameters[&quot;items&quot;])[0];

            if (item == null)
            {
                return;
            }

            IEnumerable&amp;lt;Language&amp;gt; languages = LanguageManager.GetLanguages(item.Database).Where(a =&amp;gt; a != item.Language);

            if (SheerResponse.CheckModified())
            {
                //prompt user they want to add versions
                if (args.IsPostBack)
                {
                    if (args.Result == &quot;yes&quot;)
                    {
                        foreach (Language language in languages)
                        {
                            Item localizedItem = item.Database.GetItem(item.ID, language);

                            //if Versions.Count == 0 then no entries exist in the given language
                            if (localizedItem.Versions.Count == 0)
                            {
                                localizedItem.Editing.BeginEdit();

                                localizedItem.Versions.AddVersion();

                                localizedItem.Editing.EndEdit();
                            }

                            Sitecore.Web.UI.HtmlControls.DataContext contentEditorDataContext = Sitecore.Context.ClientPage.FindControl(&quot;ContentEditorDataContext&quot;) as Sitecore.Web.UI.HtmlControls.DataContext;

                            contentEditorDataContext.SetFolder(item.Uri);
                        }
                    }
                }
                else
                {
                    StringBuilder builder = new StringBuilder();

                    builder.Append(&quot;Create version for each language?&quot;);                    

                    SheerResponse.Confirm(builder.ToString());

                    args.WaitForPostBack();
                }
            }
        }
    }
}</pre><p>This then needs to be added into the commands section of the config with the following patch file:</p><pre class="crayon-plain-tag">&amp;lt;configuration xmlns:patch=&quot;http://www.sitecore.net/xmlconfig/&quot;&amp;gt;
    &amp;lt;sitecore&amp;gt;
        &amp;lt;commands&amp;gt;
            &amp;lt;command name=&quot;item:addversiontoalllanguages&quot; type=&quot;###.Domain.Cms.Specialization.Shell.Framework.Commands.CreateVersionInAllLanguages,###.Domain.Cms&quot; /&amp;gt;
        &amp;lt;/commands&amp;gt;
    &amp;lt;/sitecore&amp;gt;
&amp;lt;/configuration&amp;gt;</pre><p>If you want this functionality available from a cms button, you need to wire up the button to the command. To do this, switch to the core database. </p>
<p>In this example we will add to the Language chunk of the ribbon (<em>/sitecore/content/Applications/Content Editor/Ribbons/Chunks/Language</em>). You need to create a new button and then setup the data section paying close attention to the Command field. This wants to be the same value as set in the patch file (item:addversiontoalllanguages).</p>
<p>The post <a rel="nofollow" href="https://blog.boro2g.co.uk/create-a-version-of-an-item-in-all-languages-in-the-sitecore-client/">Create a version of an item in all languages in the Sitecore client</a> appeared first on <a rel="nofollow" href="https://blog.boro2g.co.uk">blog.boro2g .co.uk</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.boro2g.co.uk/create-a-version-of-an-item-in-all-languages-in-the-sitecore-client/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
