Thursday, August 2, 2012

Access "Pages" Library for Chinese Locale


My site collection has 5 language variations.


Except Chinese version I am able to access Pages Library Like :

web.Lists["Pages"] or web.Lists.TryGetList("Pages")  .


But for Chinese sub site :

  1. If I Iterate   web.Lists   collection  using foreach loop , there is a list present whose SPList.Title is "Pages" . For this list Under SPList.SchemaXml , Title is Title="頁面"

  2. web.Lists["Pages"] gives error: List 'Pages' does not exist at site with URL 'XXXXXXXXXXXXXXXXXXXXXXXXX' AND  web.Lists.TryGetList("Pages")   gives null .

  3. But web.Lists["頁面"]  returns the right SPList object

Is it like , SharePoint API's to retrieve a list by name refer to  SchemaXml   rather than SPList.Title , while retrieving a list internally ?




Reply 1 by


I would propose to use SPWeb.GetList function - it returns list by url (eg web.GetList("/myweb/Pages") and url usually the same for all locales.

reply 2 By

All the options that I can come up with are:


  1. Web.GetList(<Url from SharePoint Resource File>) Preferred over the others for Intranet

  2. PublishingWeb.PagesList (Coz it was specifically mentioned for Pages Library)

  3. SPWeb.GetListsOfType ( with 850 for Pages Library. If it does not work then 101-Document Library and Loop through)

  4. Guid LibraryPagesId = PublishingWeb.GetPagesListId(web); SPList psgeslib = web.Lists[LibraryPagesId];

Also, just wanted to add Web.GetList(URL) is normally a better performing approach than Web.Lists[ID/TITLE].


Aseem Sood

No comments:

Post a Comment