Only selecting documents with a future publish from date or no publish from date in CMSRepeater

Tim G. asked on March 15, 2019 10:33

I have a simple CMSRepeater but I only want it to show documents which have either a future 'Publish From' date or no 'Publish From' date set. Ideally it would also observe the 'Publish To' field.

So I currently have:

<cms:CMSRepeater ID="rptSlider" Path="./Slider/%" runat="server" HideControlForZeroRows="true" OrderBy="NodeOrder" SelectOnlyPublished="true">

What is the correct WhereCondition for this logic? I've tried WhereCondition="DocumentPublishFrom >= getdate()" but this doesn't appear to work?

Recent Answers


Rui Wang answered on March 15, 2019 14:34

CMSRepeater only display published content to the public. It can display content not yet published in preview mode. What is your scenario of show published and content not published but has a publish from date?

0 votesVote for this answer Mark as a Correct answer

Tim G. answered on March 15, 2019 14:38

If the document isn't using a workflow though isn't it always classed as 'published'?

0 votesVote for this answer Mark as a Correct answer

Rui Wang answered on March 15, 2019 14:41

You don't need to use workflow for publish from and to. Those are schedulers, not workflow. So if you have no workflow and set a publish date of a page to be tomorrow at noon, even if you "Save/publish", it's not live until noon tomorrow.

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on March 19, 2019 07:48

You will need to set the repeater to not to select published pages only. Then, you should be able to use a variant of the WHERE condition used to get all published pages:

([DocumentCanBePublished] = 1 AND ([DocumentPublishFrom] IS NULL OR [DocumentPublishFrom] <= GETDATE()) AND ([DocumentPublishTo] IS NULL OR [DocumentPublishTo] >= GETDATE()))

So, the above condition is used to get published pages. You can modify it to fit your needs. And also, you may want to check what is the difference between content scheduling and workflow.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.