jxycms
6/21/2017 - 6:46 AM

parent pages and children pages -- use placeholder to force children pages can only change specific things. inherit content from parent page

parent pages and children pages -- use placeholder to force children pages can only change specific things. inherit content from parent page

**in helper.cs file

public static string GetHierarchyContent(string fieldName, TreeNode currentDocument)
{
    string result = "";

    result = currentDocument.GetStringValue(fieldName, string.Empty);

    if (string.IsNullOrEmpty(result) && currentDocument.NodeLevel > 0)
    {
        if (currentDocument.Parent != null)
            result = GetHierarchyContent(fieldName, currentDocument.Parent);
    }

    return result;
}

**in macro.cs file

[MacroMethod(typeof(string), "Get document content", 2)]
[MacroMethodParam(0, "Field name", typeof(string), "Field name")]
[MacroMethodParam(1, "Current document", typeof(TreeNode), "Current document")]
public static object GetHierarchyContent(EvaluationContext context, params object[] parameters)
{
    if (parameters.Length == 2)
    {
        return RenderHelpers.GetHierarchyContent(
           ValidationHelper.GetString(parameters[0], string.Empty),
           (TreeNode)parameters[1]
       );
    }
    else
    {
        return "";
    }
}

** in macro

{%GetHierarchyContent("page type property name", CurrentDocument)%}