• Basics
  • Abyss
  • Web APIs
  • C# & Razor
  • .net API
  • JS & TS API

    Show / Hide Table of Contents

    Class PublishingFilter

    Filter entities to show Drafts or only Published Entities

    The PublishingFilter DataSource is part of the Standard EAV Data Sources. It will hide unpublished items for non-editors and provide these drafts if an editor is viewing the results.

    How to use with the VisualQuery

    When using the VisualQuery you can just drag it into your query. Here's a picture showing app data with or without publishing filter:

    Configuring the PublishingFilter DataSource

    The PublishingFilter has no configuration.

    How does it work?

    Since the published/unpublished is a very common query, internally the cache actually already provides different streams for this - and the PublishingFilter simply chooses the stream based on the current permissions.

    Programming With The PublishingDataSource

    We recommend to use the VisualQuery where possible, as it's easier to understand and is identical for C# and JavaScript. It's also better because it separates data-retrieval from visualization.

    Read also

    • DataSource / DataStream
    • List of all EAV Data Sources
    • Query / VisualQuery

    Demo App and further links

    You should find some examples in this demo App

    • Demo App with examples for most DataSources

    History

    1. Introduced in EAV 3.x, in 2sxc ?

    API Documentation

    Inheritance
    System.Object
    HasLog
    DataSourceBase
    PublishingFilter
    Implements
    IDataSource
    IAppIdentity
    IZoneIdentity
    IAppIdentityLight
    ICacheKey
    ICacheExpiring
    ITimestamped
    ICanPurgeListCache
    IHasLog
    IDataTarget
    IDataPartShared
    Inherited Members
    DataSourceBase.ErrorStream
    DataSourceBase.SetError(String, String, Exception)
    DataSourceBase.GetRequiredInList(IImmutableList<IEntity>)
    DataSourceBase.GetRequiredInList(String, IImmutableList<IEntity>)
    DataSourceBase.Name
    DataSourceBase.AppId
    DataSourceBase.ZoneId
    DataSourceBase.Guid
    DataSourceBase.Configuration
    DataSourceBase.DataBuilder
    DataSourceBase.CacheRelevantConfigurations
    DataSourceBase.ConfigMask(String, String, Boolean)
    DataSourceBase.CachePartialKey
    DataSourceBase.CacheFullKey
    DataSourceBase.CacheTimestamp
    DataSourceBase.CacheChanged(Int64)
    DataSourceBase.PurgeList(Boolean)
    DataSourceBase.In
    DataSourceBase.Out
    DataSourceBase.Item[String]
    DataSourceBase.GetStream(String, String, Boolean, Boolean)
    DataSourceBase.List
    DataSourceBase.Attach(IDataSource)
    DataSourceBase.Attach(String, IDataSource, String)
    DataSourceBase.Attach(String, IDataStream)
    HasLog.Log
    HasLog.InitLog(String, ILog, String)
    HasLog.InitLog(String, ILog, String, CodeRef)
    Namespace: ToSic.Eav.DataSources
    Assembly: ToSic.Eav.DataSources.dll
    Syntax
    [PublicApi_Stable_ForUseInYourCode]
    [VisualQuery(NiceName = "Publishing Filter", UiHint = "Keep data based on user roles (editor sees draft items)", Icon = "visibility", Type = DataSourceType.Security, GlobalName = "ToSic.Eav.DataSources.PublishingFilter, ToSic.Eav.DataSources", In = new string[]{"Published*", "Default*", "Drafts*"}, DynamicOut = false, HelpLink = "https://r.2sxc.org/DsPublishingFilter")]
    public class PublishingFilter : DataSourceBase, IDataSource, IAppIdentity, IZoneIdentity, IAppIdentityLight, ICacheInfo, ICacheKey, ICacheExpiring, ITimestamped, ICanPurgeListCache, IHasLog, IDataTarget, IDataPartShared
    Remarks

    Technically many things could just identify the app they belong to, and let the system look up the zone. But this would be inefficient, so for optimization, many items identify themselves with both the app and zone Ids

    Properties

    | Improve this Doc View Source

    ShowDrafts

    Indicates whether to show drafts or only Published Entities.

    Declaration
    public bool ShowDrafts { get; set; }
    Property Value
    Type Description
    System.Boolean

    Implements

    IDataSource
    IAppIdentity
    IZoneIdentity
    IAppIdentityLight
    ICacheKey
    ICacheExpiring
    ITimestamped
    ICanPurgeListCache
    IHasLog
    IDataTarget
    IDataPartShared
    • Improve this Doc
    • View Source
    Back to top Generated by DocFX