Custom PublishedFilter

Topics: Developer Forum
May 11, 2008 at 12:12 PM
I have noticed that items in the navigation tree turn red when the item is out of the publishing scope.
Is it possible to change this behavior?

In my template base class I have a property named ‘Online’ of type boolean that extends the publishing scope.
I have added the property to give the users a quick way of making a draft and to temporarily remove an item from the web.

Also, I have created my own PublishedFilter that verifies the datetime publishing scope and the Online property.
Would it be possible to configure the N2 navigation tree to use my own PublishedFilter?
May 11, 2008 at 4:34 PM
I think there is an extension point in the INode interface:

public class MyItem : ContentItem, INode
    public string ClassNames
        get { return Online ? ((INode)base).ClassNames : "unpublished"; }

This is how the implemeantion in the ContentItem baseclass looks like:

        string INode.ClassNames
                StringBuilder className = new StringBuilder();

                if (!Published.HasValue || Published > DateTime.Now)
                    className.Append("unpublished ");
                else if (Published > DateTime.Now.AddDays(-1))
                    className.Append("day ");
                else if (Published > DateTime.Now.AddDays(-7))
                    className.Append("week ");
                else if (Published > DateTime.Now.AddMonths(-1))
                    className.Append("month ");

                if (Expires.HasValue && Expires <= DateTime.Now)
                    className.Append("expired ");

                if (!Visible)
                    className.Append("invisible ");

                if (AuthorizedRoles != null && AuthorizedRoles.Count > 0)
                    className.Append("locked ");

                return className.ToString();
May 13, 2008 at 7:42 AM

Thank you libardo… that was exactly what I was looking for.