Archive/Restore Options for Sitecore

versions

There are many legally obligated companies that would still pick Sitecore for it’s immense power and flexibility that comes out of the box and the constant push towards reaching marketing goals is one of the other main reason why.

The biggest challenges they are facing currently is the legal battles these heavy financial companies face to maintain old/stale data for compliance reasons.  Even if they have a third party crawler of some sort that would capture screenshots of how sites are rendered at scheduled times, due to Personalization and other contextual driven content, they do need some way to tap on to all history and can not risk loosing it for Audit purposes.

I have seen some clients that kept storing all versions in all languages which would lead to bad performance of content editor and slow content authoring experience.  Sitecore recommends not more than 10 versions to be stored on CM side.

I have been researching to find few decent options to steer them to correct path which is to trim their versions.  I must say that I could not find next to none which are robust and easy to use, especially that utilize Sitecore Archiving instead of Serialization to a item file on file system.  I sure found couple blogs and references to build something, but, it would be nice to have feature which would be harnessed and appreciated by most of the audit heavy clients.

Would love to get some feedback and tools you all typically use for Archiving the outdated Item versions.  Do note that this should work on a load balanced CM environment. 🙂

Looking forward to hear any feedback on this, I currently, based on research out there found three options overall and I am listing down pros and cons on each.  But, if any of you know more, please reach out.

Option 1 – Manual Route

Sitecore provides manual way for content author to archive versions on need basis and there is a UI that could be utilized to restore the version of choice.

https://doc.sitecore.net/sitecore_experience_platform/82/content_authoring/managing_items/general/archive_and_restore_an_item

Option 2 – Custom with a Twist

The Guru, John west, has a blog that is neat and could help with a solution that could be custom built.

https://community.sitecore.net/technical_blogs/b/sitecorejohn_blog/posts/rules-engine-actions-to-remove-old-versions-in-the-sitecore-asp-net-cms

Also, I did find a module that took inspiration from option 3 that is coming next and blog provided above, but, unfortunately it does not support multi-lingual at this time and customization would be needed to be able to use the same.

Introducing the ‘Sitecore Version Pruner’ shared source module!

Option 3 – The Legacy Module (Version Manager)

https://marketplace.sitecore.net/en/Modules/Version_Manager.aspx

If you have ever read through performance tuning document, Sitecore did recommend on versions 7 to have in version manager to help mitigate number of versions.

FYI, currently due to lack of time, the module is not being actively maintained per author’s comment, but, it could be tested and utilized if your business demands are satisfied.  But, do note that this uses file serialization mechanism for restoration and archiving, so, it would be tedious to restore and not as straight forward as Archiving that is possible on later versions of Sitecore.

 

I had created sitecore support ticket to find out if there is more that I can quickly go ahead and use and the answer was no, so, they created a feature request, would love to get this ticket escalated.  If you wish to track it, here is the number – 198728

Did you know – Broken links report considers all versions

broken

As soon as I come across some thing new and is a small piece of info, but, could be useful, I can immediately think about my Did you know series.  This would be a latest addition to the pile.

Interesting piece of information that I bumped in to yesterday while running Broken Links report on a huge database  and sitecore instance that has many versions on CM side of things in many different languages.  When I run the broken link report, there were huge number of items listed on the report and I randomly picked bunch of those to check more deeply.  Most of them were outdated and old versions.

I immediately thought there should be a way to force Sitecore not to consider old versions when running broken links report.  Unfortunately, there is no way to do so currently.   When I dig deeper in code of kernel, I did see the default is to consider all versions.

Code versions

I got a feature request logged with sitecore if you like to track it, here is the reference number – 178492

If you really need this feature, then, the only other way is to build your own Speak View and scanner that could be custom function to grab only the latest version of each item in each language to keep the list to what you really care about. 🙂

 

Allowed Controls Issue Fortis Dynamic Placeholders

Fortis Nuget

I know many folks out there love and use Fortis Dynamic Placeholder either via Nuget or in package form.

The following link provides some information and background about what it does.

http://fortis.ws/fortis-collection/dynamic-placeholders/

While picking a dynamic placeholder support for my 8.2 Sitecore Instance I did a lot of research to see and weigh my options and picked this as this has been actively used by many of Sitecore enthusiasts.  The hope was it will be seamless and easy to use.  It was both of these on many levels and so far was working fine for our requirements.

On this specific implementation of Sitecore, we do use a lot of modules with placeholders for re-use and ease of dropping different type of content within the parent wrapper for instance.  It gives immense flexibility and power when done right.  I was skeptical that we would potentially run in to an issue or two, but, was also confident that this module is backed up by Habitat as well along with about 60k downloads on Nuget that any issue could have a potential solution.

Issue :  When you have a placeholder within a Dynamic Placeholder , this inner placeholder could be a sitecore one or dynamic one, incorrect allowed controls were showing up on Inner placeholder.   It was actually pulling allowed controls of parent(wrapper) instead of inner placeholder.

Steps to resolve:  I decided to approach the channel and folks I know who love/recommend Fortis, unfortunately none of them yet encountered this issue of mine.  So, I decided to debug further.  The issue is in the patch that the module does before Sitecore.Pipelines.GetPlaceholderRenderings.GetAllowedRenderings to get the allowed controls of placeholder based on regex match and add it to list of renderings.  For this patch, if you use dotpeek or reflector, you will notice the below lines of code :

Match match = new Regex(PlaceholderKeyRegex.DynamicKeyRegex).Match(placeholderKey1);
if (!match.Success || match.Groups.Count <= 0)
return;
string placeholderKey2 = match.Groups[1].Value;

What this does is get the match from the args placeholder key that Sitecore pushes in to see if this is a dynamic type of placeholder and if it is, it tries to look in to groups to find the value and correspondingly get the Allowed Controls on placeholder in question.  This is an issue because it is by default picking up the first match and not considering the most inner match possible.

I revamped this piece of code to use Regex match collection instead and pulled up the most inner one available and that seems to do the trick.  I will attach the fix below for your reference if you are curious.  I left rest of the code untouched to ensure I introduce no bugs. 🙂

Note:  Still under testing and not been shipped to live site, so, use this with caution.

Regex regexForPlaceholderKey = new Regex(PlaceholderKeyRegex.DynamicKeyRegex);
var allMatchesOnPlaceholder = regexForPlaceholderKey.Matches(placeholderKey1);
Match match;
if(allMatchesOnPlaceholder.Count > 0 )
{
//Always get the highest match, last match as that would be needed for allowed controls
//If there is just one matcg it should still get the first one
match = allMatchesOnPlaceholder[allMatchesOnPlaceholder.Count-1];
if (!match.Success || match.Groups.Count <= 0)
return;

After you change, ensure you patch your config to your updated code for this specific pipeline process code. Observe caution when you upgrade Fortis Nuget version for instance in the future before swapping the config file.
If I were you, I would test the below scenarios post change to ensure all is well.  Go to experience editor and click on Add Here on each of the corresponding cases in design mode.

1. A simple sitecore placeholder
2. Sitecore placeholder inside a parent placeholder
3. Simple Dynamic Placeholder
4. A Dynamic placeholder inside a Dynamic placeholder
5. Sitecore placeholder inside dynamic placeholer.
6. If possible/existing use case – Dynamic placeholder inside Sitecore placeholder

Hope this helps some one like  me. 🙂
Logged an issue on git hub page for this Nuget reference as well.

https://github.com/Fortis-Collection/dynamic-placeholders/issues/3

Did you know – Paas does not support Lucene

So psyched to share this quick piece of info, this is my first time working with a fully Sitecore Paas infrastructure, so, getting to know it more intimately.  I did know that Sitecore Paas comes with Azure Search and Redis cache for instance, but, what I did not know is that Lucene is not at all supported which means that all Lucene related config files were actually disabled on the upper environments that were set up with help from Sitecore.

Reality hit me hard when trying to set up a computed index field that worked beautifully fine on my local, but, completely broke on upper environments.

So, folks out there if you are using Paas pay attention to the index configuration and ensure all the steps listed below were actually completed thoroughly on your Paas  sitecore servers.

https://doc.sitecore.net/sitecore_experience_platform/setting_up_and_maintaining/search_and_indexing/configure_azure_search

Two quick follow up questions that would come to mind, how do I know which type of Search Indexes are used, this is the simple one, look at showconfig.aspx to see what is listed under Index configuration which defines type of Index.

Index Info

The second one which is more important when there is custom search/Index based functionality is, how to ensure locally too Developers are using Azure based Indexes and not Lucene based one’s?  Would love to hear from every one who has experience on this.  This would be an open question for now, hoping to resolve this based on feedback and would potentially reach out to Sitecore to understand what do people generally do for Development in this case.

Happy Sitecoring and hope you are all enjoying your holidays!

Sitecore Shared Content Issues

On the day one, when I started my blog, I made a promise that I will share good and not so good side of Sitecore.  So far, did not find anything that was very counter intuitive up until now.

One of the main purpose of CMS is to share a piece of repetitive content so you are not changing something in ten different places when there is a need for change, you change one single datasource item that is shared across multiple pages and all pages will reflect the change when the datasource is pushed live either via a workflow based approach or through some kind of publish.

But, the stinky part is that when this specific datasource is shared across multiple pages, all pages will be in some sense updated, but, are never thrown in to a workflow of any sort, they just magically are updated on live website.   In many heavy compliance driven environments, it get’s super important to track when a page or any content living on the page has changed.  With current inherent behavior of Sitecore, there is no way to track when a page truly changed due to datasource driven modules and how the page and datasources are disconnected for many good reasons.

When asked, Sitecore mentioned that this is possible to do so by tapping and finding related items of the datasource and doing something with those layered related items.  It just seems surprising to me that this is not something that is available out of the box.

Below are few references I read up while ensuring that I am not some how dreaming or in an illusion and that Sitecore does support this behavior.  Sitecore confirmed that, nope, the page items that use a datasource that has been modified do not go through any workflow and will not be published.

https://doc.sitecore.net/sitecore_experience_platform/content_authoring/creating_and_editing_items/editing/manage_associated_content

Suggested approach is that you use the Link database and get all references as stated above which per me seems to be expensive operation especially if you do not have a workflow set on datasource templates for instance.  In which case, you will already be pushing all datasource templates as true related items when a page is published.

I would love to hear what others do in situations like this.  This feature when implemented could come in handy in many situations with all clients that are more Compliance driven due to legal aspects of the site and information they would need to track.

Example of sample approach to read from Link database is below.

https://laubplusco.net/sitecore-item-extensions-get-referrers-as-items/

 

Did you notice that Image Dimensions are missing? Resolve it!

There are times when you bump in to this issues which feel like are present in out of the box version, when you are confident that it is Sitecore issue, feel free to put in a support ticket, they are usually prompt in getting back, especially, if this issue has been known to be existing.  Similar thing happened when our QA logged a bug for us which states image dimensions are missing on tree view and look fine on the other view.  See screenshot below as a reference.

Support got back in no time and here is the patch for the same if you are on version Sitecore 8.2 and above.

https://sitecore.box.com/s/ecmo5ybmsmeoshbd8t6o2xidwcc8n383

With Helix, it gets a little tricky to apply these kind of patches by Sitecore.  Below are the steps I followed, hopefully it helps some one who is looking for some guidance on the same.

  1. Go to Sitecore Official and Nuget sources to see if there is already a package by Sitecore, I am assuming on critical sitecore patches they would release Nuget packages to ensure folks can use from the same repository to battle their issues.
  2. In my case, the issue is minor, so obviously could not find a patch that was a Nuget, I made my own Nuget and hosted it on our company Nuget Server.  If you do not have your company one and are working with set of local developers, you could ask them to create a Local repository on some shared location and host the package from there.
    Note: Ensure your build servers also have access to that shared location. 🙂
    I added this Nuget package as reference to Common project under the project layer of Helix implementation.  Essentially, the Nuget in my case had just a dll and static javascript file that is loaded by the view in question.

That is it!  Issue behind us and we move forward to attack other fun problems.

Did you Know – A thing to do when reading from children

Super excited to post my second post on ‘Did you know’ series. This is in relation to thing/step that developers could potentially forget as they were so happy that they wrapped up a module that was complex, but, still felt super simple with help of Glass to get children loaded with exact object types they need and performance efficient and maintainable code as they parse through the list of objects only once. 🙂

How cool, right?

But, what about your content author who uses Experience Editor for them daily chores of adding/updating modules. We tend to forget them often in this busy world of making functionality. The mantra “They are the ones who use the system when you call it done and deploy the code”. So, remembering them for nth time, lol, to ensure they are still happy, do not forget to add Insert option to Experience Editor buttons that show up on the rendering. Go to your rendering that has children being read as part of implementation and add in Insert as an option to show up.

A picture is better than 1000 words, here you go:

Another problem you would need to address when you utilize children is to ensure when an item (Datasource item) is published, the children of that particular item are also published when related items are pushed. Out the box sitecore does not do that, pay close attention and ensure you customize it.

Helpful link for this publish issue:

Deep Publishing Of Related Items With Sitecore Experience Editor

Did you know – Caution on what you pass to Editable fields on Glass Mapper

Glass and Sitecore

Welcome to my series “Did you know”, I will keep posting as and when I find interesting issues and how I solved them.  This would a tiny tidbits of information which could help some one in need.  Some times you spend half day resolving an issue only to realize how petty that was. 🙂

I wish I could find a blog on each of these issues, the reason I choose to post is because I could not find a Blog or direct link to these type of issues.  Pesky little issues that eat our brains out, well, hope this helps some one.

Problem:  Very weird behavior on Glass Editable controls, specifically on looping an object, all is well when you run the debugger, but, when you actually visit the live page or preview mode the problem shows up.  On Experience Editor though things might look okay.

Resolution:  I spent hours thinking my objects are not correct, data is not loaded properly by Glass as I was mapping the children and then looping over them.  No errors on logs either.   Finally! light at the end of tunnel, the paid attention to Model being passed to @Editable Glass fields, the Engineer was copy pasting this line of code by passing it as generic X, so, it is up to Glass to decide what the object is vs we clearly stating what is the object over which we expect the looping to occur.  Once I passed in the Model using the override method of this Html control, everything starting working on all modes preview, EE and live mode.

Example Usage:  @Editable(Model, x => x.Title) //explicitly stating the model

Helpful References :  http://glass.lu/Mapper/Sc/Tutorials/Tutorial22

Hope this helps!

Thought of the day:  I am super jealous with all folks at Sitecore symposium right now, hope to join you all next year. :)

Best Practices for any Sitecore Project

With every new project, the situation is a little bit different, some times you feel like you have the whole time in the world and sometimes time is just not enough no matter what.  It depends on timeline, scope, budget and many many other things actually.

In my recent Sitecore project I am working on, fortunately I am getting enough time to craft and think about every single decision on my way.  This feels so good as I can beautifully craft a solution that is great functionally and from marketing perspective.

With start of every build phase of the project, based on team and project, I make a quick checklist for Developers and team to go over before they submit for code review.  It does not  take a lot of time, but, will go long way to ensure we are implementing Sitecore to take advantage of out of the box functionality it has got, it is important to remember why Clients chose Sitecore and ensure the set up is done right to satisfy their needs, both functionally and from content authoring/Marketing perspective.

Below is one such list and I make effort to keep that updated as the team moves towards attempting complex modules.  The mantra is to build out smaller and keep updating it based on pitfalls you generally see in your team.

  1.  Follow Technical Breakdown as closely as possible, if something should be done differently, please collaborate with Technical lead that had done the breakdown and mention the same, so he/she is aware
  2. Assume that any or every object could be null and ensure null checks are in place on your controller or business logic code.
  3. Minimize code or branching in view, in fact, we recommend to have literally no code, except for simple if statements that would check before editable/property is outputted on the view.  Everything should be available on Model or View Model that is passed and logic should reside in Controller.
  4. Create and check in all sitecore items on to project that the module or feature would need.
  5. Ensure Helix patterns and principles are followed and applied.  Technical breakdown should provide guidelines on the same as well.
  6. Do not forget to set proper Insert Options and Standard values based on functional requirements.  This is a must for a seamless content author experience
  7. Datasource and Data Template are required and is usually specified on datasource driven modules on the Technical Breakdown
  8. All fields such as pickers like Multilist, droplist or Images should be having a source assigned to ensure proper funneled content is shown to content author when trying to load content and keeping media and datasources organized and secured.
  9. Helptext, which are hints for the content author should be added when ever there is back end logic to decide on priority between two fields or specific scenario happens when user fills in a specific content field.  Talk to your Technical lead when in question.
  10. Every thing that is stated editable should be allowed to be editable and unit tested on Experience Editor, consider adding custom experience buttons / Edit frames to edit background images and pop over text when applicable. Other options could be explored if scenario could not be addressed with such easy to configure tools.
    1. If there is a drop list or a picker on content editor, such as theme selection or pattern selection, etc., consider adding a custom experience button to ensure content author could edit the same from Experience Editor.  Refer :  https://community.sitecore.net/technical_blogs/b/maximizing_usability/posts/enhancing-the-page-editor-experience-with-custom-experience-buttons
  11. Ensure your module implemented works on Experience Editor and in fact editable entities are correctly edited and saved via the platform.
  12. Ensure to upload a new image for Thumbnail for ease of use by content author and to look professional and intuitive.  Look in to document uploaded on sharepoint for instructions on how to do the same.  Document Name:  Steps To Upload Thumbnail Image For Rendering.docx
  13. Do error handling when needed and may be a back end service is being used to gather information on controller.  Use methods available on Sitecore.Diagnostics to ensure to push the error to logs, it would be helpful while debugging an issue on upper environments
  14. If there an RTF, ensure a source is set up that pulls up capabilities listed on documentation.
  15. At early stages of the implementation, I would recommend for ease of checking and testing process, the new rendering/module should have at least one set of sample content checked in and this rendering should be added to standard values of Generic Template, a new content page should be instantiated under Home node of the instance and if not dynamic data source, a specific data source should be picked to ensure when the page is accessed the module would show up on the website.
  16. Use the power of Glass to load everything you need on your datasource object or TDS Class, it is easy to extend and tell Glass what type of object you want and map it with few attributes and as simple as that, you get everything you need and controller is clean. Avoid writing code when you don’t have to.

Journey with Helix

Hi There!  With new project I am getting an opportunity to work with Helix patterns, along with leading a team who is awaiting instructions and pointers from me, I am re-inventing and looking at sitecore from a totally different perspective.  Since, the whole sitecore world is moving towards Helix and embracing it, I was bent to take a step forward as well.  I am subtly nervous about this, but, hey, we got a a great team both internally and in community who would pitch in to help us take some decisions.

As I roll along, I plan to share what I learned and how we solved each question/concern that came up while implementing Helix for the first time ever.

Two of them so far.  Below are those noted and steps I took based on recommendations of my fellow super stars.  Do you agree? Do you have some totally different direction that we could lean towards.  I would look forward to getting some different thoughts around this.

  1. Helix does not support base page template and advice to have the page templates inherit from several interface templates instead.
    • Pain point – This would mean, every time there is a need for Global interface template to be added to all page templates, some one has to go to each template and add that in.  Hopefully, if architecture is planned correctly, this should not happen very often, but, yeah, I might have to install powershell for sure to do bulk operations very soon.  I can totally see it.
    • I had no option left at this time other than manually adding couple of those sections that are Global to all templates.
  2. Helix proposes to use a different project per feature/module, but, I guess I agree to use grouping instead to group tightly related siblings(I think you may call it that) in to one project instead.  For example, you have similar looking Hero Slider modules, but, we all know that there is not just one Hero on your website, you will have different flavors for this kind of modules.  So, instead of creating one feature project for each Hero, we tend to group them in to one Feature project instead.  Keeping this balanced, like not abusing it, but, at the same time judging each module case by case basis.
    • In this paradigm, I feel a little confused once in a while especially when Client says any module could be used any where on the site, well technically you could use any module any where on Sitecore, assuming not too many restrictions are placed using placeholder settings, but, saying all modules are Global kind of puts the categorizing in terms of Helix in jeopardy or confused state.
    • What I did to overcome this is – Think about different ways of grouping a module based on name of the module, fields/sitecore items in use for the module, where this module is likely to be used, what is the generic purpose of this module.  Few such questions I answered to myself to give clarity on naming the feature projects.  If the module seems to be really generic and not fitting in to any category, we would then plan to drop it under Modules project.  Again, being careful to not abuse this.

Will definitely bump in to more. Also, cool find, I see that the unit testing feedback provided on Helix/Habitat is pretty cool if you wanna check out

http://helix.sitecore.net/devops/testing/unit-testing.html

Performance is the Key

Imagine yourself building an excellent functional website, but, it does not load fast enough, would people actually use the awesome functionality you pulled off.  The answer would be no! People are impatient and busy with their hectic lives and they would not care to wait 3 seconds that the functionality might take to load.  So, performance is a balancing act to make wise decisions when coming to impeccable functionality.  Asking the right questions and following the best practices around everything as much humanely or scope wise possible is the way to to go and key to success.  In the past, i did write a blog about performance gain in few steps which was more web site page load speed driven.  You can see it here

A different paradigm to bump up your site performance

This time around, I will highlight few key things you could do in improvising your Content management experience.

When building a sitecore site, considering the routine and daily chores of content author are the most important to ensure we are using full potential of what Sitecore has to offer with it’s platform.  But, often times this is forgotten along the way and more attention is given to how the website looks, feels and functions.  It is important to ensure the content author experience is still taken in to consideration while pulling off an amazing looking site.

Couple things to keep in mind while coming up with Architecture and Sitecore content structure for the site –

  1. Placeholder settings
  2. Insert Options
  3. Experience editor support
  4. Available renderings
  5. Compatible Renderings
  6. Standard Values

I will drill more on to how each of the above when thought and configured correctly would be of great help to ensure content author has seamless experience.  For now, jumping on to performance.   I have seen many folks complain that their content authoring is slow and sometimes take a while to load.  This could be due to customization done, but, we should not forget to try the below things first to ensure we have basic foundations covered.   They do not take long time to do, but, could be that it is often given least importance because again end user experience is given more weight  than content author experience. 🙂

Below is the drill that could be done to instantly bump up your content author experience.

  • Clean up Databases :  It should be either done regularly via control panel or a script that could be scheduled to run from SQL server to help mitigate performance issues.
  • Maintenance Plans: Sitecore performance tuning guide screams that this is important, it is simple to do, but, I noticed this is almost always ignored and not done.  This is important and critical for content authoring performance
  • Ensure there are less than 100 items within a node, this is a best practice suggested by sitecore, so, the content author does not click on expand and wait few seconds before he see’s the list load.
  • Few critical settings that could help content tree load would be those mentioned on performance tuning document, below are the two for reference, both have good gain of performance
    RenderCollapsedSections
    CheckHasChildrenOnTreeNodes
    Check tuning guide for more information:  https://sdn.sitecore.net/upload/sitecore7/70/cms_tuning_guide_sc70-72-usletter.pdf
  • Limit number of versions: User version manager to ensure you have upper bound to number of versions on your implementation.
  • Ensure workbox and draft versions are cleaned up frequently for better maintenance and quicker load.
  • Clean  up broken links
  • Rebuild your indexes
  • Use publishing service if you are on newer versions of sitecore.
  • Go cloud – So, nearest available node would serve the content avoiding any network delay
  • Ensure you set cache limits and not use limitless cache option that sitecore provides on CM
  • Check your logs for any errors and fix them.

After doing all the above, if your content authoring is still slower then look into any overridden code in Sitecore pipelines and do some performance tests.

Happy Sitecoring and Have a great weekend!

Glass Surprise – Get Your Ancestors like a champ

Glass just makes me so happy! I do not have to write same 10-15 lines of code every time to do something very mundane when it comes to Sitecore. Every other feature on sitecore demands some kind of relationship driven items to be accessible from context page on which your module would do some magic on. Typically, developers tend to write their own custom code to do such things which would lead to bad performance when not done right. Why not just go with Glass if you are using it in your instance development? It is far more easier. I had done a similar blog post to grab children from Glass, but, this time around it is Ancestors. Though similar, it could help some one who did not think or know that it could be used on both the relation ships on the tree, upwards or downwards. Steps to do this is quite simple and three step process Declare a custom partial class that extends your auto generated class based on say a template. For example like below. I like to keep these guys organized, usually do it in special Model project and namespace related to it, to keep things easy and manageable, so some one can easily know if the model has been extended. Next up, add a Attribute that comes with Glass such as below, pass your template ID. I actually tried getting this ID from a config setting which would have been great for maintenance, see if you can do that based on your project settings Access the new ancestor strongly typed( A bonus, so you dont need to cast and make a messy view, the view simply get’s what it needs and you access and ensure your checks are in place)

Sample Code Of Custom Partial Class namespace

YourProject.Models {

public partial class Your_Template_Auto_Generated_Clas{

[SitecoreQuery(“./ancestor-or-self::*[@@templateid='{7E6BC980-362C-4BBB-97E5-9DAA83B70812}’]”, IsRelative = true)] public virtual Your_Strongly_Typed_class myAncerstorItem { get; set; }

} }

Voila!

Goal accomplished and the best part clean code, clean views and happy MVC.

Have a great weekend ahead!!!

Custom Sorting on Coveo Facet

I got to use a new feature of Coveo today because of new requirements. How fun, though the request that came through felt not needed and a corner case in terms of user experience. Pushing through limit is what we have to do if you have got super picky clients. 🙂
The outcome is always precious as you get to learn something new. Here is the snapshot of what happened and how we were able to get it working per request and requirement.

Goal – Regardless of selections made on Coveo Facet because of url appending, the sort order of values available on facet stay per the field on which sort is based on.

Problem – The inherent default behavior of Coveo for better UX experience. To be honest, I actually like what they have in terms of grouping the values selected to the top and rest are sorted based on the sort field set up. But, we have to some how overwrite this default behavior.

Firstly, our front end contact explored why this happens and how coveo groups them the way it does inherently. The reason for special attention that these selected values get is because of the below. Thanks to our front end resource to find this out. Though we did not pursue anything in modifying this, it is always good to know the reasons behind how it is currently done.

https://developers.coveo.com/display/public/SearchREST/Group+By+Results

So, the reason is that when there is an appending in URL for a selection of a value or set of values in the facet, Coveo inherently tags these as Desired and hence the special treatment for those to be on the top.

For example, if your URL is like below may be because the user clicked on back button post user selected few values and moved on his journey, the user could land on pages like this or if marketing team linked off the user to a page with pre-selected values on a facet.  There could be more scenarios where your user would bump in to this situation, but to name a few.

Example URL – https://www.domain.com/press-releases-events-and-webcasts-landing#f:articlePostYear=[2017,2018]

The selected would be grouped on top like below due to the above explained reason.

Again, I like what Coveo does inherently and I suspect that this needs to overridden in simple cases, but, if you absolutely need to do this? Which is where we stood, I logged a Q and A below and luckily got a direction.  I only wish there were more graceful options, but, we took what we got as well, we had to overwrite this and there was no other option unfortunately.

If you are curious, follow the discussion here and I will explain more in detail how I actually implemented what was recommended by Coveo team.

https://answers.coveo.com/questions/12071/facet-values-mentionedgrabbed-in-allowed-values-be.html?childToView=12086#answer-12086

Steps I did to Implement this solution:

  1. Created a copy of default Coveo MVC view for facet and named it differently and placed under correct project specific location.
  2. Add the below line to the view created just above end of div tag in place for the facet
    data-custom-sort=”2024,2023,2022,2021,2020,2019,2018,2017,2016,2015,2014″>
  3. Note – With addition of this, we should be good on sorting with lower limit of 2014 to upper limit of 2014, based on your project data you could decide on good numbers for these limits. Only deal is post 2024, if this project has same implementation, we will need a code deploy to ensure sort works as expected.
  4. Use this new view item on presentation for the facet and select all appropriate values that a coveo facet would need on the templates affected or will use such type of facet
  5. That is it!! Post this change regardless if values are selected via url or not, the ordering will be based on data-custom-sort.

Sitecore Launch Hiccups and Resolution

I know it has been a while, Vacationing and launch has been no joke on my side. 🙂
It has surely taken a toll and kept me away from blogging for quite a few days.  Finally, today I got some time to jot down the experiences of my launch after a pause.

Time Taken: 14 hrs straight starting 5.00 PM to Mid night around 2.00 AM PST, it was a grueling long night and I was supporting the go-live from India, how fun!

Sadly, I did not expect any issues or what so ever because we had code already up and running on the actual servers with all the things working and QA/UAT pass.  The only thing that was changing was DNS and binding being different, rest everything was absolutely same.  Well, everything does not happen as planned especially on the launch day.   I was supporting using a fairly fast internet for Indian standards, but, still fell a little short as I was used to things being done fast.

Below are few hiccups and how we resolved each of these, hope it helps some one who is stuck in a similar situation.

  1. xDB Cloud working excellent on sandbox license, but, lot of issues when swapped to prod license.    While launching the site, we obviously have to swap the connection strings to use production xDB license provided by sitecore.  We did so, but, as a surprise we encountered bunch of errors on logs and had to re-visit all the related configs to ensure we did everything as expected.  Sitecore did not mention in support ticket that extra steps would be needed on live license which are additional as compared to non-prod xDB license.  We followed the below blog and added host file entry as mentioned and left hostname empty on configuration. https://sitecorehacker.com/2017/02/12/sitecore-analytics-tracker-common-issues-and-how-to-resolve-them/
  2. IIS security hardening done prior to enabling anonymous access to the site.  It is kind of common practice that when we have a pre-prod or staging site behind some kind of authentication to ensure site is not publicly available since it is meant to be.  As part of deployment strategy, we had steps listed and unfortunately they were ordered incorrectly.  Since, enabling anonymous on parent site would trigger that change to all children and folders within the site, the hardening we had done per sitecore recommendations on CD servers was lost and we had to re-do the steps.  These things add time post launch especially on VPN, connected to remote servers from INDIA. lol
  3. Coveo cache – Still unsure what was causing Coveo to access a URL that is no longer configured on either Server URL or for that matter any where else.  While rebuilding master index, it kept failing saying that could not reach to a binding which is no longer available.  I am assuming it is some kind of cache, unsure where or what at this time.  I ensured there was no trace of old/outdated URL any where by going to /showconfig.aspx and also reviewing coveo configuration files.  Still a mystery to solve, but fortunately the error did not mean indexes were not built, so, we were safe to move forward and were successfully able to rebuild other web and liveweb indexes with out errors.
  4. Cache – It is a boon and blessing.  We had set up cache on all renderings applicable.  But, there was a slight miss.  Parent placeholders that carried WFFM should not be allowed to cache, but, there were few misses which were uncovered only on regression testing that few forms were not working, once we removed cacheable setting on these renderings forms started working like a charm.
  5. Errors on Log files –  It is important to monitor log files to check for any major errors on the logs that clutter the server and could have slow response times.  We un-covered a few and still in progress on identifying all the outstanding issues.
  6. Redirects –  On our lower environments we had few different settings like www was being forced as it was not needed which was enabled post launch as a requirement.  This started throwing off the logic and plan around redirects.  We had to revamp the redirects loaded to ensure they are working alright and corrected few instances.  Especially when migrating or unifying multiple sites this could pose a challenge.  How I wish we had exact same settings and tested the logic against that to reduce this back and forth.
At the end, all was well.  I am glad we stretched it instead of calling it off, it is a worst feeling to do a rollback.  Launch would mean a great move in the forward direction, never would want to associate it with a failure.  I am glad the site went live and has been appreciated both internally and public facing.
Looking forward to more adventures in the future.
Happy Weekend every one!

A different paradigm to bump up your site performance

You might have seen ample number of blogs, information and other resources out there that talk about the same topic.  But, I will try and make this in steps, so you have step-by-step guide all in here and you will surely spend less time scraping this data from 10 other places.
At the end, I will also list references on where I gathered all this from, so, you can refer and read more if you are an enthusiastic reader.

Have you heard about Google page speed extension?  If you did not, it is fine and I will not say you were living in a cave, in this functional desire world, I wonder why performance is always addressed at the very end of the tunnel in software life cycle.  I would go ahead and say a simple performance test plan should be part of every step of implementation.   It could be simple, but invasive.  It would help mitigate surprises which usually take time to resolve.

There are tons of tools out there as well to measure performance, but, I got hooked on to Google page speeds extension as it is easy to visualize and Google does do a good job of providing links to problems that were uncovered which would provide good insight to multiple solutions to the problem on hand.

Let us get this started –

1. First do not expect anything,  don’t assume that your site is great or worst in terms of performance.  Just download the extension of your favorite choice, I like the Google Page Speeds extension, but, you could run anything
2. Address to one’s Google put’s more weight on and are in red.  I think that would be the critical one’s for sure.  I did the following and saw immediate boost on numbers

Images and Images (Scaling and Optimization)

Firstly ensure you are scaling images on server side (Using Glass params) instead of depending on content authors to upload files of certain dimensions.  Though we tried to enforce this through documentation and collaboration, we still saw lapse.
Best way to battle this is use Glass params, then, regardless of whether recommended size is respected or not, your browser will not spend ton of time sizing and re-sizing images to fit your FEE needs(css)
Get the params based on FEE recommendations, the best thing to do is set width and let height be auto.

Example :@RenderImage(carouselSlide, m => m.Carousel_Image, new { @class = “carousel__image”, w = 684, width = 684 }, true, outputHeightWidth: true)
Please re-upload all imagery that is not respecting the dimensions.  This is important for performance and critical
Also, ensure good/web optimized imagery is loaded on to media library.  If tool complains that some images could do better in terms of performance, please re-upload the culprits.  Should be quick and the tool offers a download option on each of the offensive currently uploaded image.  Go to sitecore editor and do simple attach/detach.  You are done.
Make sure all your site specific css/js is minified and only those minified versions are accessed in your HTML or view code
Ensure web server has compression enabled.  This is a simple check of a checkbox available on IIS under compression for a specific site(Ensure static compression is checked).  Sometimes, if installation is not done correctly even if you checkbox this it might not work.  Please ensure this works by looking at Network request and content-encoding attribute is being set as ‘gzip’.  You can check in fiddler or on Google chrome by toggling the column display to show this response header.  If you dont see gzip, please check with support once you ensure you have enabled the IIS settings properly and things seem off.  This is v important for performance and must be ensured is working
Enable cache control on static resources on web.config to ensure you enable this after talking to your FEE team on what would be a good max age time.  It could vary based on multiple things and should be verified with your team.

After these steps, please follow sitecore performance tuning guide no less than Bible(link in references), go over all content delivery preferences and ensure you set all of them correctly.  When in question about something please check with your support team.

That is it, you just made your sitecore instance super efficient.  The tuning guide should also cover caching best practices which should bump up good performance benefit second load on wards.

Happy Sitecoring!!

Few Good References

https://developers.google.com/speed/pagespeed/insights/
https://sdn.sitecore.net/upload/sitecore7/70/cms_tuning_guide_sc70-72-usletter.pdf
https://chrome.google.com/webstore/detail/google-pagespeed-insights/edbkhhpodjkbgenodomhfoldapghpddk?hl=en
https://developers.google.com/speed/docs/insights/EnableCompression