0

Normally in order to get the current document in K13, we must use DI to get the IPageDataContextRetriever.

However, when trying to register a custom macro field, adding a constructor to my class (in order to use DI) prevents the class from registering:

[assembly: RegisterExtension(typeof(MyMacroFields), typeof(TreeNode))]
public class MyMacroFields : MacroFieldContainer, IService
{
    public const string TitleMacro = "MyMetaTitle";
    public const string DescriptionMacro = "MyMetaDescription";

    private readonly IPageDataContextRetriever _pageDataContextRetriever;

    public MyMacroFields(IPageDataContextRetriever pageDataContextRetriever)
    {
        _pageDataContextRetriever = pageDataContextRetriever;
    }

    protected override void RegisterFields()
    {
        base.RegisterFields();
    }
}

Is it possible to use DI somehow? Or is there another way to get the current document?

1 Answer 1

0

There is a how to article here that solves the issue:

https://devnet.kentico.com/articles/building-an-integration-(stripe)-part-3-helpers-and-event-handlers

Your Answer

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

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