Wednesday, April 29, 2015

Sitecore - Item language

Sitecore 'items' and 'languages'

Hi all, in this post I like to discuss some little things that you might like to know when you are playing with the Sitecore items and langues.

1. Get the languages of an item.

Item currenItem = (Get the current item to the variable) - The way of getting the item can be different the method you are using and the parameters.

                    Language[] langs = currenItem.Languages;

2. Get the  item versions of an certain language

                    foreach (var lang in langs)
                        var langItem = currenItem.Database.GetItem(currenItem.ID, lang);
                        var vers = langItem.Versions.GetVersions();

3. Get the fields of an item

                     latest.Fields.ReadAll();   //This will provide all the fields in the item
                     var fields = latest.Fields;

Hope this is useful.

No comments:

Post a Comment