Wednesday, 30 September 2015

Code Generation Error While Using Sitecore TDS + GlassMapper

Most of Sitecore developers are now using TDS and GlassMapper in their solution. It's an awesome combination!

But you may find some challenges when you are setting up auto code generation feature of TDS by using GlassMapper. One of such challenge is facing the code generation error as shown below.

So are you facing same error? If yes, then you are at right post.




Solution is very simple!

We found that when you download GlassHeader.tt and GlassItem.tt file, it has one extra blank line added in last line. Thanks to my colleague Mahek who helped me on this.

Remove this last blank line as suggested in below screens, and regenerate the code - you are done!



Hope this will help all those who are setting up TDS and GlassMapper in order to take advantage of auto code generation feature.

Have a Happy Sitecore Journey!

Friday, 18 September 2015

Sitecore Informatics Module: Now Compatible with Sitecore MVC Project!

Friends - many of you have already used Sitecore Informatics Module in your Sitecore Webform Project. If you have not used it yet, then give it a try - you will like it!

If you want to know more about Sitecore Informatics then visit my previous post about it. Sitecore Informatics will help you to view all your Sitecore Projects details at one place.

The information such as:
  • Total number of Sites in your Sitecore instance
  • Total number of Sublayouts in your Sitecore instance along with referrer pages and caching parameters
  • Total number of Templates in your Sitecore instance along with referrer pages
  • Total number of Content Items in your Sitecore instance
  • Total number of Media Items in your Sitecore instance
  • Total number of Users in your Sitecore instance

If you are using MVC in your Sitecore Project then previous version of Sitecore Informatics may not help you. Since I got few requests about MVC project support, thought to update this module and share it with community.




You can now download updated version from Sitecore MarketPlace: 
https://marketplace.sitecore.net/Modules/Sitecore_Informatics.aspx

You can also download source code along with Sitecore Package from github:
http://nileshthakkar.github.io/Sitecore-Informatics/

Hope you will enjoy this module!!!

Wednesday, 9 September 2015

Speed Up Your Sitecore Experience Editor Ribbon

This post is inspired from Sitecore Documentation article Improve the performance of the Experience Editor ribbon.

I will try to elaborate the same stuff by including step by step configuration and test case.

For any website, one of the crucial things is to improve it's performance. And one of the ways to gain the performance is to implement caching. So far as Sitecore is concern, we usually focus on live website by caching JS and CSS using different approach such as bundling and minification.

But what about Page Editor or Experience Editor performance? Experience Editor loads few extra Sitecore resources in order to render ribbon. So it would be really helpful if there is a way to cache this Sitecore Ribbon. In-fact, there is a way to accomplish this - and this blog post is all about that!

So let's see how to cache Sitecore Experience Editor Ribbon to improve site performance.

Steps:
1) Open [Sitecore Instance]\Website\sitecore\shell\client\Speak\Layouts\Layouts\Speak-Layout.cshtml

2) Add below string to the <HTML> tag.
 manifest="/sitecore/shell/client/Sitecore/ExperienceEditor/Html5AppCache.ashx"

So it would look like this:


That's it, you are done!

But you may have question - How can I confirm whether it's working? How can I check whether it's really caching Sitecore Experience Editor Ribbon?

You can confirm it by looking into Application Cache as shown in below figures.

Before ribbon caching:



After ribbon caching:



Hope this will give a smile to your Experience Editor user :) !!!

Special thanks to Martina who assisted me on this.

Sunday, 6 September 2015

How To Enable/Disable Code Generation For Particular Item in Sitecore TDS Project?

All of us know how to configure auto code generation in Sitecore TDS Project? It's very simple - you just need to select Enable Code Generation as shown in below figure.



But what if you want to exclude few items from this auto code generation? If you have such requirement then this post may help you.

Suppose you have configured Enable Code Generation for your Sitecore TDS project, so it will auto generate code for all of items under that project. Now if you want that some of items under that project should not be part of this auto code generation, then you can achieve it by configuring Code Generation Template property of all those items as highlighted below.


Configuring Code Generation Template as None will exclude that item from auto code generation and setting it back to blank will consider that item for auto code generation.

Wednesday, 2 September 2015

How to Access User Location - Latitude and Longitude?

You can now take advantage of HTML5 Geolocation API in order to get user's location details such as latitude and longitude.

What was our requirement?
1) Whenever user visits our website, we want to track user's location (e.g. latitude and longitude).  
2) Page should ask to access location only one time during that session, it should not ask every-time.
    Using geolocation API will ask user to whether user wants to share location or not?

Implementation:
Below code snippet shows how to use HTML Geolocation API and store user's location details in cookie so that it should not ask to share location each time.

Step-1:
Define two hidden textboxes to store user's latitude and longitude value.
   
   
Step-2: Write jQuery to access user's latitude and longitude and store it in cookie for future use.

HTML5 Geolocation API browser compatibility:
If you want to know which browsers support HTML5 Geolocation API then below screen-shot can help you.



User will be asked to share location only one time, then it will be stored in cookie for future use.



Hope this may help you to trace your user's location!

Is Dropdown Postback Not Working in Sitecore?

Wondering why your page is not getting postback when you select any dropdown item even-though you have set AutoPostback property to true?

If so, then it can be fixed by adding below configuration in your web.config file under    <typesThatShouldNotBeExpanded> section.
      
    
        System.Web.UI.WebControls.Repeater
        System.Web.UI.WebControls.DataList
        System.Web.UI.WebControls.GridView
        System.Web.UI.WebControls.ListView
        System.Web.UI.WebControls.FormView
        Microsoft.Reporting.WebForms.ReportViewer
        Telerik.Web.UI.RadGrid
        System.Web.UI.WebControls.LoginView
        System.Web.UI.WebControls.DropDownList