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
Demo App and further links
You should find some examples in this demo App
History
- Introduced in EAV 3.x, in 2sxc ?
API Documentation
Implements
Inherited Members
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 SourceShowDrafts
Indicates whether to show drafts or only Published Entities.
Declaration
public bool ShowDrafts { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |