Hmm, even using the coupled data option, the MacroResolver is still returning an empty string. It seems as if the MacroResolver context cannot resolve the reference to the custom field property set on the page (i.e. AuthorBio
in this case). Here is my current test code for completeness:
var coupledPage = tree.SelectSingleNode(page.NodeID, CultureHelpers.GetCultureCode(), true, true);
// The following property is inherited from its parent page - this contains the macro
// text that we want to expand - "{%AuthorBio%}"
var metaDescriptionMacro = coupledPage.GetInheritedValue("DocumentPageDescription").ToString();
// This variable is used to check that the actual 'AuthorBio' property is populated
var actualBio = coupledPage.GetValue("AuthorBio"); // This is populated as expected
// Here we try and get the macro defined in 'metaDescriptionMacro ' is expanded
// This returns an empty string
var metaDescription = MacroResolver.Resolve(metaDescriptionMacro);
This can actually be simplified (for the purposes of debugging) to:
var coupledPage = tree.SelectSingleNode(page.NodeID, CultureHelpers.GetCultureCode(), true, true);
var metaDescription = MacroResolver.Resolve("{% AuthorBio %}");
Which raises the question, how does the MacroResolver
know what to resolve against?