Tuesday, March 21, 2017

Preview Site Not Pickup Correctly In Multi-Site Setup For Preview OR Experience Editor On Sitecore 8 Versions

Recently I was working on a project where we converted the existing single site setup into multi-site setup.

After the conversion to multi-site setup, there were few issues reported related to local site settings were not pick-up correctly. Following are the few issues reported

Issue 1 :

When try to open Experience Editor from Sitecore Launch Pad, it didn't open the correct local site, but open the Eperience Editor for default site (i.e. "website")



Solution:

This was mention on several articls and the solution was to

1) Open the “/sitecore/client/Applications/Launchpad/PageSettings/Buttons/ContentEditing/ExperienceEditor” item in the core database
2) Change the “Link” field value to: /?sc_mode=edit&sc_resolvelanguage=0

https://community.sitecore.net/general/f/11/t/2835


Issue 2 :

When try to open the Experience Editor for an item from Content Editor, it always set the "sc_site" parameter to "website". So, it also was not picking-up the correct context site.

website.local?sc_mode=edit&sc_itemid=%7bB338C802-17A7-4D71-A5E8-4E6C4B7EEC6E%7d&sc_version=3&sc_lang=en-US&sc_site=website



Solution:


Sitecore has reported this as a known issue and has provided fix in the following knowledge base article.

Quote:
In multi-site Sitecore solutions, the Preview functionality of the Content Editor or Page Editor may incorrectly resolve the site the previewed item belongs to.The context site may be resolved according to the value of the Preview.DefaultSite setting, or set to website as default.

https://kb.sitecore.net/articles/382913

After the above fix is implemented, site context site resolved correctly.

website.local?sc_mode=edit&sc_itemid=%7bB338C802-17A7-4D71-A5E8-4E6C4B7EEC6E%7d&sc_version=3&sc_lang=en-US&sc_site=US

Friday, March 3, 2017

My First Major Sitecore PowerShell Extension Workout

One of my recent tasks was to make a content node with child items to fallback to "en" language version, for all existing languages.

Since there were lot of child items, I thought to use the Sitecore PowerShell module and do it using script.

Sitecore PowerShell Extension module can be downloaded from https://marketplace.sitecore.net/en/Modules/Sitecore_PowerShell_console.aspx

During my task, I faced several obstacles. But all solved using PowerShell scripts.

First thing I did was Google..

I found following article, which contains most of the functionality I needed.

https://mtgeekblog.wordpress.com/2016/11/30/first-blog-post/


Then, I needed to restrict the code to only change workflow state on all the language except "en" language.

I posted my question on Sitecore Slack Chat in #module-spe channel.

(In case if you are not yet a member of Sitecore Chat channel, you can send a request to access it using https://docs.google.com/forms/d/1bAVDgP5-FhFh8ohPchHtifq-rz7EBkuPojAzdEofJyo/viewform?edit_requested=true )

Luckily, Sitecore PowerShell module creates was on Sitecore Slack Chat Channel also. They helped with that problem.

get-childitem . -recurse -Language * | where-object { $_.Language -ne "en" }

Then, I faced another strange issue. When run the following script, it only returned few language versions per an item. But, I know there were lot of other language versions for this same ite.

get-item . -Language * | Format-Table Id, Name, Language, __Workflow, "__Workflow state", "__Default workflow"

What I find out was, we are using Sitecore "Language Fallback" feature on these items. When that "Language Fallback" checkbox is checked, it somehow only took few item versions.

But, No problem. I ran following script on the child items, which sets the "Enable Item Fallback" checkbox Un-Checked. Then run the scripts. Then again make the "Enable Item Fallback" checkbox Checked.


Another Issue I faced was, when I try to remove language versions from an item, the script didn't do anything.

That is also caused by the Language Fallback feature. So, When you are running version related scripts (EX: Checking the language versions, Removing language versions, etc), first make the "Enable Item Fallback" Un-Checked, before running the Script.


From todays experience with Sitecore PowerShell Extension module, I understand that it is a must have tool for Sitecore Developers.

I will post more about the things I learn with PowerShell Extension in coming days.

Happy Sitecore and Sitecore PowerShell :-)