ASP.NET, CMS

Sitecore Custom Publisher

In Sitecore, both developers and content authors often comes across the situation where they need to publish multiple items which do not belongs to same parent. But unfortunately, Sitecore does not provide option for this.

Let’s consider following scenario.

 

Node A

                    Child a1

                    Child a2

                    Child a3

                   Child a4

Node B

                  Child b1

                  Child b2

                 Child b3

 

Here, I want to publish Node A, child a1, child a2, child a3 and child b2. To do this, we need to manually select and publish each item one after the other.

 

To overcome this, I created a custom publisher(simple aspx page), using which Sitecore user can select and publish multiple items from the Sitecore tree in a single go.

First create a simple aspx page with empty divs to hold Sitecore tree and languages list.

Aspx:

Add reference to jstree js and css files.

Html:

 

 

Then create the webmethods to get Sitecore tree, list of available languages and to publish the selected items on clicking the publish button

 

Get list of languages available in Sitecore:

 

Publish items on clicking publish button:

 

Now lets render the Sitecore tree and languages using ajax calls.

Get Sitecore tree on page load:

 

Get languages list on page load:

 

 

Publish items on clicking publish button:

 

 

Using this custom publisher user can either select the items from the sitecore tree on the left or enter comma(,) separated item ids in Items Ids text area.

Once the items are selected, select language to publish from Select language(s) list on the right side of the screen and click Publish

All the items that are selected in the Sitecore tree and the Items id textarea will be published.

 

References:

JS Tree: https://www.jstree.com/

 

 

About The Author