Sunday, April 13, 2014

Possible Sitecore Hackathon as part of Sitecore User Group Conference 2014

Back on January 24, 2014 something amazing happened, the First ever Sitecore Hackathon.  9 Teams from various nations took part and had lots of fun.  Thanks to Akshay Sura (@akshaysura13) for arranging the first one.

Its looks like the next one will take place in person at the end of the Sitecore User Group Conference 2014
If you are able to take part please register here.  Also please forward on the registration information to everyone you know.  The more teams taking part the more fun it will be.

Look forward to Twitter commentaries and hearing the results of all the amazing modules that will come out of this.  Also look forward to many more.


Thursday, April 10, 2014

Sitecore 7, The Data Source and the GUID

For those looking at upgrading from Sitecore 6.x to 7.x beware of a subtle advancement that is very beneficial in most situations but a major issue in another.

Scenario #1:  A client is migrating from an existing CMS and pulls the content from the existing cms into Sitecore on a regular basis during migration to reduce the size of the outage windows for Clients.

Scenario #2:  A client injects data into Sitecore from an external system via clearing all the nodes under a certain node in sitecore and then re-imports the content items.

In both these scenarios the Guid would chance for the content item but the path would remain the same.
In Sitecore 6.6, this would work fine as the DataSource property of the sublayout stored the Item Path.

In Sitecore 7.0, a cool advancement was introduced that allowed you to move content around and it would automap the DataSoure much like it does with content links.  Nice feature but in the above scenarios it will break existing SubLayouts.

Workaround: This is not ideal but if you place text in front of the item path eg. "ITEM_PATH:" then sitecore cannot resolve the sitecore path so it will keep the string there.  Then in the sublayout when you grab the DataSource you look for that string and remove it before calling GetItem.  Here is some sample code:

                if (string.IsNullOrEmpty(subLayout.DataSource))
                    return Sitecore.Context.Item;
                string dataSource = subLayout.DataSource;
                Item dataSourceItem = null;

                if (dataSource.StartsWith("ITEM_PATH:"))
                {
                    dataSource = dataSource.Substring(10);
                }

                if (Sitecore.Context.Database.GetItem(dataSource) != null)
                {
                    dataSourceItem = Sitecore.Context.Database.GetItem(dataSource) ??
                                      Sitecore.Context.ContentDatabase.GetItem(dataSource);
                    Log.Info("CurrentContextBased On Data Source (" + dataSource + ")", this);
                }

Alternatively someone could override part of the mechanism to handle "ITEM_PATH:" much like Sitecore itself does currently with "query:"  If someone has created one, and is willing to share it in MarketPlace for others to use, let me know and I will reference it here for others to access.

If you have any tips, tricks or resources you would like to share with the Guild please email them to chris.williams@threepointturn.com or dennis.augustine@threepointturn.com and we will share them with the Guild.