-5

I have a content type called "daily".

I created 7 nodes titled: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday. I have a view that shows this content type where it set to show only one node. I need it to show only the node named Monday every Monday and the node Tuesday on Tuesdays, etc. and repeat.

I have been experimenting but can't find an answer since I can't sort this view in a way to show only Saturday on Saturdays and so on.

Note that this was a simplified version of what I want. I really have 366 nodes which I want to repeat every day of the year. Each node must show on the view dependent on today's date.

How to do that?

Here are things I tried: I tried to un-publish content every 360 days and republish (+5) days. This won't work because some years are 366 days. I also tried to use the repeat date where the repeat date is every 1 year. I found out that when I sort by repeat date field, it brings the earliest date first. I can't make it dependent on current date

0

2 Answers 2

1

I am not sure what you mean by not a forum. I was able to resolve it. Here is how i did it: I created the following nodes with an unpublish date as follows: Sat to be unpublished next Sat Sun to be unpublished next Sun Mon to be unpublished next Mon, and so on for all 7 nodes of the week

Then I created two rules: 1) schedule unPublish Event. Event: After updating existing content of type Event. Condition: Content is published. Action: rule: Set scheduled unpublishing date 2) Publish unpublished content now. Event: After updating existing content of type Event. Condition: NOT content is published. Action: Publish content

4
  • "not a forum" is just a commentary on the format here - instead of putting vital information in the comments, just make sure it's in the question. If you find you have more to add after it's been asked, you can just edit it rather than commenting. Sounds like a small thing, but it's actually important for keeping the site clean and tidy :)
    – Clive
    Commented Sep 28, 2015 at 14:18
  • How is this going to work in a year from now? In your question it says that you wanted to repeat it every year. So what is then (in a year from now) going to be the trigger of your Rule(s)? At that time you will NOT be creating the nodes anymore that you created now, right? Commented Sep 28, 2015 at 19:40
  • Yes, it does work. 1) schedule a node to unpublish in one year using the normal scheduler in the node itself 2) Create a rule that publishes (now) any node that has been unpublished 3) Create another rule that schedules any Published node to be unpublished one year from now 4) Sort the view by Unpublish date - desending
    – yogi Moh
    Commented Sep 28, 2015 at 19:58
  • However, the only problem I got is this: My schduler works with cron. So there is always a delay in unpublish and publish date (the discrepancy between the cron run time and the rule). Currently I have the unpublish rules is set to (+1 year). I need to over write the time of the day to be exactly at 4:00 am of that unpublish date. Basically, I need to unpublish date to be: (+1 year) at 4:00 am. I don't know how to do that, anybody?
    – yogi Moh
    Commented Sep 28, 2015 at 20:02
0

Part 1: Views between dates filter

Refer to How to filter events between two dates for detailed documentation about how you can make this work, using the Views between dates filter module. Here are some more details about this module (from its project page):

This Views filter provides the between date functionality you've been looking for by answering the question: "What events are on this date?" It displays all content (comparing start and end dates) occurring on a specified date.

Creating this functionality with standard Date filters requires two filters: start date less than or equal (<=) to the supplied date and end date greater than or equal (>=) to the supplied date. The problem is two filters means users must enter a date range, when technically selecting "September" is a range: September 1st to the 30th.

It compares two date fields with one supplied date. Effectively it is the opposite of the standard Date Views "between" operator, which compares one date field with two supplied dates.

This module can be used to filter events on ONE date (and NOT a range of date, as its name suggests!).

To use this approach, it is required that you already have a content type with a date field. It is not necessary to have two fields to adjust an "end date" for the event, only a date field with the "Collect an end date."

Part 2: Update the dates to next year

With the approach described in "Part 1", you should be able to achieve your goal for the first year already. To make it work after 1 year also, you should create a mechanism to automatically update the date field you're using, to add "1 year" to the date stored in the date field.

There are a few possible approaches to do this. One approach is like so:

  • Build a view to list the nodes for which the date in the date field has passed, and use the Views Bulk Operations module to transform that list in something that can be processed by the Rules module.

  • Create a Rules component to process the nodes in this list, which updates the date field (to add "1 year" to the date stored in the date field).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.