Over the past few months I have been spending more time getting familiar with useful features in Sitecore Rocks in an effort to boost productivity. Below are some of my favorite features. I will not be covering how to set up Sitecore Rocks within Visual Studio. This link will take you to the setup of Sitecore Rocks within Visual Studio: http://vsplugins.sitecore.net/default.aspx.
When developing within Sitecore a lot of the times we need to clear the caches in order to see changes. Instead of using [local]/sitecore/admin/cache.aspx to clear the caches, Sitecore Rocks has all the caches accessible in Visual Studio. Here you can clear specific caches or even clear all caches without leaving Visual Studio. Simply right-click on the caches area and you will see the options.
Quick Item Creation for Testing of Repeated Items
Sitecore developers know all too well that when developing we are going to be using databound controls such as ASP.NET ListView server controls to display repeated items from the content tree. Instead of duplicating one item at a time using the Sitecore Content Editor we can create all these items at once to do some testing, which will save us Sitecore developers a bit of time just to see if our code is functioning as intended. All you need to do is open up Sitecore Explorer and click on the item where you want to add the items as children, then click Ctrl-A. This will bring up the “Add New Item” dialog box:
Now, you simply select the template and how many items you want to create. In the above example I select the Repeat template and add 3 more items. Now, I have 4 “Repeat Template” items in the content tree as children of the item selected initially:
Creation of Items from Files
Maneuvering between Sitecore Content Editor and Visual Studio can be a pain when you want to create a layout or sublayout and then tie it to the layout or sublayout item in the content tree. Sitecore Rocks helps us Sitecore developers by giving us the ability to create items from the Web User Controls or Web Forms within Visual Studio. Below is an example of a basic Visual Studio Sitecore solution:
Using the above example, I want to create a sublayout item in the content tree using the “Sandbox Sublayout.ascx” web user control. To do this I simply right-click on the web user control and hover over Sitecore where I see another window open up and I click on “Create Items From Files…” (if this option is not available you will need to connect the solution to the databases by right-clicking on the solution and then hovering over Sitecore, then click “Connect…”). Now you will see the Create Items from Files dialog box:
Now we simply select where we want the item created. In the above example I select the “layouts\sublayouts\Sandbox” folder in the Master database then click on OK. Now I get the Log dialog box that shows me that the item was created:
Now if I refresh the content tree in Sitecore Explorer I can see the new item I created from the file in Visual Studio:
If I view the sublayout item I can see the path is correct to where my file is located in my basic Visual Studio Sitecore solution:
Publishing Items and Dependencies
Another useful feature of Sitecore Rocks is the ability to publish items and their dependencies. This comes in handy when you may have don’t may have forgotten what was associated with the item such as the layouts, sublayouts, template, etc. So instead of having to remember what was associated with the item, Sitecore Rocks will take care of that for you and publish the item AND it’s dependencies. For this example I have created an item in the content tree called Sample Item which is using the Sample Item template that comes out of the box with a standard Sitecore installation. In the Layout Details, I am using the Sample Layout, also out of the box with a standard Sitecore installation, and then set the Sandbox Sublayout as the rendering using the Content placeholder:
Now, if I right-click on the “Sample Item” in the content tree and hover over “Tools”, then hover over “Publishing”, I will then see the “Publish Item and Dependencies…” option. When clicked upon we get the Publish dialog box with the dependencies that will we can select to publish. Notice the Sample Item, Sample Layout, Sandbox Sublayout, and Sample Item template:
Now, when we click on the OK button all the dependent items will be published and this relieves us from some of the guesswork involved in our day to day Sitecore development.