2

I created a Tenant under which I have multiple Sites. I want to access the Settings folder of each Site and perform some action on it.

This is the current structure: Tenant ABC contains Site ABC. Site ABC has basic SXA Site structure, having items like Home, Data, Media, Presentations & Settings. I want to access the Settings folder of all Sites under my Tenant ABC.

Thanks for the help.

1
6

You can try something like the following:

var contextItem = Context.Item;
if (contextItem == null) return;

var siteItem = ServiceLocator.ServiceProvider.GetService<IMultisiteContext>().GetSiteItem(contextItem);

var settingsItem = siteItem?.Children["Settings"];
if (settingsItem == null) return;
1
  • 5
    FYI - IMultisiteContext has a GetSettingsItem method on it :) even easier
    – Richard Seal
    Jul 31 '19 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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