0

I created an customfield, the class implemented like below:

public class GoogleMapField :Sitecore.Shell.Applications.ContentEditor.Text, IContentField
{}

In this class I want to get current content itemID is using this customField in ContentEditor. I tried to use ItemID property but It's not success

public string ItemID { get; set; }
4
  • Do you mean you want page item id where form has applied? Aug 2, 2019 at 6:02
  • I mean. I have a item use that custom field. Then I want to get that item id in the code that implement my custom field. Aug 3, 2019 at 10:24
  • Take a look at Rich's answer here, it may help: stackoverflow.com/questions/32498571/… Aug 3, 2019 at 13:16
  • @Hugo that post is nothing to do with custom content editor fields, that's for ContentSearch fields in an index
    – geedubb
    Sep 29, 2022 at 6:53

1 Answer 1

1

This has always been an issue. Using GetItem(), just returns the Content Editor Item in the core Db. What I ended up doing was a bit of a kludge but it works. In my Render method I did this:

var id = !string.IsNullOrEmpty(ItemID)
                        ? ItemID
                        : ControlAttributes.Substring(ControlAttributes.IndexOf("//master/", StringComparison.Ordinal) + 9,
                            38);
   var item = new ID(id).ToSitecoreItem(db);

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.