Class PublishingFilter
- Namespace
- ToSic.Eav.DataSources
- Assembly
- ToSic.Eav.DataSources.dll
The base class for all DataSources, especially custom DataSources. It must always be inherited. It provides a lot of core functionality to get configurations, ensure caching and more.
Important: in most cases you will inherit the CustomDataSource DataSource for custom data sources.
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
Demo App and further links
You should find some examples in this demo App
History
- Introduced in EAV 3.x, in 2sxc ?
API Documentation
[PublicApi]
[VisualQuery(NiceName = "Publishing Filter", UiHint = "Keep data based on user roles (editor sees draft items)", Icon = "visibility", Type = DataSourceType.Security, NameId = "ToSic.Eav.DataSources.PublishingFilter, ToSic.Eav.DataSources", In = new string[] { "Published*", "Default*", "Drafts*" }, DynamicOut = false, HelpLink = "https://go.2sxc.org/DsPublishingFilter")]
public class PublishingFilter : DataSourceBase, IDataSource, IAppIdentity, IZoneIdentity, IAppIdentityLight, ICacheKey, ICacheExpiring, ITimestamped, IHasLog, IDataSourceLinkable
- Inheritance
-
PublishingFilter
- Implements
- Inherited Members
Remarks
Had a major, breaking update in v15. Consult the guide to upgrade your custom data sources.
Properties
ShowDrafts
Indicates whether to show drafts or only Published Entities.
[Configuration(Fallback = null)]
public bool? ShowDrafts { get; set; }
Property Value
- bool?