0

I retrieve all the lists in the current web using:

foreach (SPList list in SPContext.Current.Web.Lists) 
{}

This works well. The problem is that when a user changes languages, and is routed to the variation, for example:

en-US/Site1/Page1.aspx to 
fr-FR/Site1/Page1.aspx

the 'foreach' loop looks in the 'fr-FR/Site1' for the lists instead of 'en-US/Site1'.

How can I always make sure I am looking in the 'en-US' variation of any site for a list of all lists?

2 Answers 2

1

If you have a list which you want to use for all variations it would be better to place that at the root site instead of at the site of one of the variations.

But if it's in a web part (or other control) running in the context of one of the sites in one of the variations you can use the following to find your lists.

Variations.Current will give you the current Variations object.

Variations.UserAccessibleLabels on that object will then give you a list of VariationLabel objects.

When looping through the VariationLabel objects you can check one of the properties like Title, IsSource, Locale or Language to find the VariationLabel where you have your lists.

Finally you can use the VariationLabel.TopWebUrl of that VariationLabel to get the SPWeb and then the lists.

1
  • Thanks for the feedback. This seems like what I'm looking for, I will make an attempt and let you know. Jun 28, 2013 at 14:16
0

Here you go, 2 nice article to read Stefan Goßner's Variations Guide, and a Waldek Mastykarz. You need to,first, locate another(en-Us) site collection, and, second - get the righ list. Variations Labels list (site.RootWeb.List[site.RootWeb.AllProperties["_VarLabelsListId"]]) helps you locate the en-Us url of the target site collection to work with.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.