Skip to content

Instantly share code, notes, and snippets.

@dnstommy
Last active May 6, 2018 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnstommy/2e7a3f567eb21611a7f1eb1bdbb5d7a7 to your computer and use it in GitHub Desktop.
Save dnstommy/2e7a3f567eb21611a7f1eb1bdbb5d7a7 to your computer and use it in GitHub Desktop.
public class ProfileCardMacro : IRuleMacro
{
public void Execute(XElement element, string name, UrlString parameters, string value)
{
Assert.ArgumentNotNull((object)element, "element");
Assert.ArgumentNotNull((object)name, "name");
Assert.ArgumentNotNull((object)parameters, "parameters");
Assert.ArgumentNotNull((object)value, "value");
var selectItemOptions = new SelectItemOptions();
var obj1 = (Item)null;
if (!string.IsNullOrEmpty(value))
obj1 = Client.ContentDatabase.GetItem(value);
var path = XElement.Parse(element.ToString()).FirstAttribute.Value;
if (!string.IsNullOrEmpty(path))
{
var obj2 = Client.ContentDatabase.GetItem(path);
if (obj2 != null)
selectItemOptions.FilterItem = obj2;
}
selectItemOptions.Root = Client.ContentDatabase.GetItem(WellKnownIdentifiers.ProfilesContainerId);
selectItemOptions.SelectedItem = obj1 ?? (selectItemOptions.Root != null ? selectItemOptions.Root.Children.FirstOrDefault<Item>() : (Item)null);
selectItemOptions.IncludeTemplatesForSelection = SelectItemOptions.GetTemplateList("{0FC09EA4-8D87-4B0E-A5C9-8076AE863D9C}");
selectItemOptions.Title = "Select Profile Card";
selectItemOptions.Text = "Select the profile card to use in this rule.";
selectItemOptions.Icon = "Business/16x16/chart.png";
selectItemOptions.ShowRoot = false;
SheerResponse.ShowModalDialog(selectItemOptions.ToUrlString().ToString(), "1200px", "700px", string.Empty, true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment