Wednesday, January 18, 2017

Select Multiple Languages In Publishing Wizard For Old #Sitecore Versions




Now this is the default sitecore feature to select all language in the publishing wizard in the newer version of sitecore.

But still if you are working on the old version of sitecore < 7.2, and want to implement the functionality where you can select all the languages on one click means Select All checkbox in the publishing Wizard? So I am here to help you for the same implementation by this blog.


This blog post is especially for the user who is using older version of sitecore < 7.2.
I was engaged one of the sitecore project which is running on 7.1 version and they are using more than 18 languages in the website and client wanted to such a feature where they can select all the languages by one click means select all checkbox, also should behave like toggle means selectall and unselect all.
So I just digged into the sitecore publishing wizard and found that there is a publish.xml which is rendered in the wizard as iframe, internally it call one page called 

·      \Website\sitecore\shell\Applications\Dialogs\Publish\publish.xml
·      /sitecore/shell/Applications/Publish.aspx?id=%7B110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9%7D 

I got the idea where I need to hook the new checkbox I just added new alllanguage selector checkbox in the publish.xml and wrote one javascript function which calls on click of new checkbox.

Adding a new checkbox was very easy task as below:
Add input tag inside the LanguagesPanel groupbox



<Groupbox ID="LanguagesPanel" Header="Publish Language" Margin="0px 0px 16px 0px">

              <input id="SelectAlllanguages" style="margin-left: 8px;position: relative;top: 6px;" value="All-langauges" type="checkbox"/>
              <span style="    position: relative;top: 4px;font-weight: bold;">
                <Literal Text="Select All Language" />
              </span>
              <Border Padding="4" ID="Languages"/>
   </Groupbox>
 



Now the only thing is to plug the javascript code with newly added checkbox. On the click of selectall checkbox, all the below checkbox should be checked or unchecked.

So below is the javascript code for the same:


jQuery(document).ready(function ($) {
    $('#SelectAlllanguages').click(function () {
        $('#Languages').find(':checkbox').attr('checked', this.checked);
                 });
   });

So after doing some research i am able to give JS reference in the Publish.xml.
I have placed this code in one JS file named publish.js and placed under
\Website\sitecore\shell\Applications\Dialogs\Publish\Publish.js
And give reference of  jquery library and newly added publish.js file in \Website\sitecore\shell\Applications\Dialogs\Publish\publish.xml file as below



<control xmlns:def="Definition" xmlns="http://schemas.sitecore.net/Visual-Studio-Intellisense">
  <Publish>
    <WizardForm  CodeBeside="Sitecore.Shell.Applications.Dialogs.Publish.PublishForm,Sitecore.Client">
      <Script Src="/sitecore/shell/Controls/Lib/jQuery/jQuery.noconflict.js"></Script>
      <Script Src="/sitecore/shell/Applications/Dialogs/Publish/Publish.js"></Script>






Now check the final result as below:

Newly added checkbox has been added in the list by name: Select All language



On the click of selectall checkbox, all the below checkbox would be checked or unchecked as below:


I hope this article will help you.

Happy Sitecoring