Skip to main content
added 1 character in body
Source Link
Alexander
  • 1.4k
  • 2
  • 7
  • 27

To resolve device item, you can use this:

var deviceItem = Sitecore.Data.Items.DeviceItem.ResolveDevice(pageItem.Database);

Then you can use one of the approaches below:

  1. Sitecore.Context.Device = deviceItem; // doesn't validate deviceItem
  2. Sitecore.Context.Data.Device = deviceItem; // validates deviceItem
  3. using(new DeviceSwitcher(deviceItem)) { // you*your code herehere*/ }

You also can use the switchers below (if needed) to switch Context.Database and Context.Item if they are null:

  1. using (new DatabaseSwitcher(pageItem.Database)) {}
  2. using (new ContextItemSwitcher(pageItem)) {}

To resolve device item, you can use this:

var deviceItem = Sitecore.Data.Items.DeviceItem.ResolveDevice(pageItem.Database);

Then you can use one of the approaches below:

  1. Sitecore.Context.Device = deviceItem; // doesn't validate deviceItem
  2. Sitecore.Context.Data.Device = deviceItem; // validates deviceItem
  3. using(new DeviceSwitcher(deviceItem)) { // you code here }

You also can use the switchers below (if needed) to switch Context.Database and Context.Item if they are null:

  1. using (new DatabaseSwitcher(pageItem.Database)) {}
  2. using (new ContextItemSwitcher(pageItem)) {}

To resolve device item, you can use this:

var deviceItem = Sitecore.Data.Items.DeviceItem.ResolveDevice(pageItem.Database);

Then you can use one of the approaches below:

  1. Sitecore.Context.Device = deviceItem; // doesn't validate deviceItem
  2. Sitecore.Context.Data.Device = deviceItem; // validates deviceItem
  3. using(new DeviceSwitcher(deviceItem)) { /*your code here*/ }

You also can use the switchers below (if needed) to switch Context.Database and Context.Item if they are null:

  1. using (new DatabaseSwitcher(pageItem.Database)) {}
  2. using (new ContextItemSwitcher(pageItem)) {}
added 210 characters in body
Source Link
Alexander
  • 1.4k
  • 2
  • 7
  • 27

To resolve device item, you can use this:

var deviceItem = Sitecore.Data.Items.DeviceItem.ResolveDevice(pageItem.Database);

Then you can use one of the approaches below:

  1. Sitecore.Context.Device = deviceItem; // doesn't validate deviceItem
  2. Sitecore.Context.Data.Device = deviceItem; // validates deviceItem
  3. using(new DeviceSwitcher(deviceItem)) { // you code here }

You also can use the switchers below (if needed) to switch Context.Database and Context.Item if they are null:

  1. using (new DatabaseSwitcher(pageItem.Database)) {}
  2. using (new ContextItemSwitcher(pageItem)) {}

To resolve device item, you can use this:

var deviceItem = Sitecore.Data.Items.DeviceItem.ResolveDevice(pageItem.Database);

Then you can use one of the approaches below:

  1. Sitecore.Context.Device = deviceItem; // doesn't validate deviceItem
  2. Sitecore.Context.Data.Device = deviceItem; // validates deviceItem
  3. using(new DeviceSwitcher(deviceItem)) { // you code here }

To resolve device item, you can use this:

var deviceItem = Sitecore.Data.Items.DeviceItem.ResolveDevice(pageItem.Database);

Then you can use one of the approaches below:

  1. Sitecore.Context.Device = deviceItem; // doesn't validate deviceItem
  2. Sitecore.Context.Data.Device = deviceItem; // validates deviceItem
  3. using(new DeviceSwitcher(deviceItem)) { // you code here }

You also can use the switchers below (if needed) to switch Context.Database and Context.Item if they are null:

  1. using (new DatabaseSwitcher(pageItem.Database)) {}
  2. using (new ContextItemSwitcher(pageItem)) {}
Source Link
Alexander
  • 1.4k
  • 2
  • 7
  • 27

To resolve device item, you can use this:

var deviceItem = Sitecore.Data.Items.DeviceItem.ResolveDevice(pageItem.Database);

Then you can use one of the approaches below:

  1. Sitecore.Context.Device = deviceItem; // doesn't validate deviceItem
  2. Sitecore.Context.Data.Device = deviceItem; // validates deviceItem
  3. using(new DeviceSwitcher(deviceItem)) { // you code here }