4

Is there a way to filter the content editor tree to only display items in the tree if they have Japanese versions?

1 Answer 1

2

Not out of the box. In theory, you will need to override the Content Editor Form. It is found in the following path: website\sitecore\shell\Applications\Layouts\IDE\Editors\Content Editor\IDE Content Editor.xml

You will need to change the CodeBeside and set it to your custom namespace. I decompiled the code, and if I am not mistaken, you will need to change the following method to accommodate your requirement:

protected virtual Sidebar GetSidebar()
{
    Sitecore.Shell.Applications.ContentManager.Sidebars.Tree result = new Sitecore.Shell.Applications.ContentManager.Sidebars.Tree();
    result.ID = "Tree";
    result.DataContext = new DataContext()
    {
        DataViewName = "Master"
    };
    return (Sidebar) Assert.ResultNotNull<Sitecore.Shell.Applications.ContentManager.Sidebars.Tree>(result);
}

You can also override the Tree Method to make it take into consideration of the language version you require.

In the Tree Class, you will need to override the following method to pass the language version.

public virtual string RenderChildNodes(ID parent)
{
    Assert.ArgumentNotNull((object) parent, "parent");
    Assert.IsNotNull((object) this.FolderItem, "FolderItem");
    Item currentItem = this.FolderItem.Database.GetItem(parent, this.FolderItem.Language);
    HtmlTextWriter output = new HtmlTextWriter((TextWriter) new StringWriter());
    if (currentItem != null)
    {
        foreach (Item filterChild in this.FilterChildren(currentItem))
        this.RenderTreeNode(output, filterChild, string.Empty, filterChild.ID == this.FolderItem.ID);
    }
    return output.InnerWriter.ToString();
}
4
  • Are you sure this will affect the content editor tree and not just the sections and fields?
    – Gatogordo
    Commented Nov 3, 2016 at 7:48
  • Yes I am pretty sure. For field section, it makes use of the <getContentEditorFields> Commented Nov 3, 2016 at 7:51
  • Can you elaborate on what should be done in the custom filter, as in the code you refer to I can only see args.EditorFormatter.RenderSections ?
    – Gatogordo
    Commented Nov 3, 2016 at 8:07
  • I have updated the answer based on more detailed investigations Commented Nov 3, 2016 at 9:13

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.