2

I am using Drupal 7(.40 or .41) and what I am trying to achieve is to completely change a pages content at a specific time & date (00:00:01 01/01/2016 to be specific)

Because the content changing is about 90% of the page, I presumed that I could set a node to unpublished at 23:59:59 with the alias and then publish the new node at 00:00:01 with the same alias. However it throws up an alias is in use error.

There is nothing obvious in my URL Alias config (/admin/config/search/path) that would indicate this is possible so I am probably looking at it the wrong way, short of using a different URL.

Thoughts and methods would be welcome.

3

I would use the Rules module for this. But you can't "rely" on the Rules Scheduler in this case, if you want the redirect to start happening as of 00:00:01 01/01/2016 (sharp).

Redirect old path to new path

Here is the rule you'd need for it (in Rules export format, just use copy/past to import it in your own setup):

{ "rules_redirect_an_alias_at_a_scheduled_time" : {
    "LABEL" : "Redirect an alias at a scheduled time",
    "PLUGIN" : "reaction rule",
    "ACTIVE" : false,
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "init" : [] },
    "IF" : [
      { "AND" : [
          { "text_matches" : { "text" : [ "site:current-page:url" ], "match" : "the_old_path" } },
          { "data_is" : {
              "data" : [ "site:current-date" ],
              "op" : "\u003E",
              "value" : 1451602800
            }
          }
        ]
      }
    ],
    "DO" : [
      { "drupal_message" : { "message" : "Please note that the old path (= the_old_path) is no longer in use, you will be redirected automatically to its corresponding path (= the_new_path)" } },
      { "redirect" : { "url" : "the_new_path" } }
    ]
  }
}

A few more tweaks to make it fit your exact scenario:

  • change all occurences of the_old_path to the path to be used until 00:00:00 01/01/2016.
  • change all occurences of the_new_path to the path to be used starting from 00:00:01 01/01/2016.

Whenever such redirect actually happens, the user will also receive an informational message like so:

Please note that the old path (= /the_old_path) is no longer in use, you will be redirected automatically to its corresponding path (= /the_new_path)

If you don't want such message to appear, then just delete the line containing drupal_message in the exported rule above.

Attention: this exported rule uses UTC times ... if your question is about another timezone, make sure to also tweak the value of 1451602800 to fit your needs.

Redirect new path to old path

If you don't want to have the new path be shown yet BEFORE 00:00:01 01/01/2016, then just create a similar rule like the previous one, in which you swap the the_old_path and the_new_path, and reverse the test on the site:current-date.

  • Thank you for this rule. This fits what I want it to do perfectly and having tested it this morning I can understand how it works. – Darren Whittenham-Gray Dec 31 '15 at 9:17
  • Although this worked in testing, on the night it went into a redirect loop. When I went in to correct things it turned out that the old_path page had unpublished itself (I don't remember asking it to do that) and I suspect that as I had a number of items scheduled to publish and unpublish that this might have been a factor as they all linked into each other. – Darren Whittenham-Gray Jan 1 '16 at 9:07
0

You need to set rules which schedule node to be published on specific time after cron run it would automatically be published.

  • I did think about that and took a look, and a second look after your comments. I think for what I am going to be using it for there is too much potential for it to go wrong (in my test it unpublished one page but did not adjust the URL of the second, so it didn't publish) , so I am going to use a second URL alias. – Darren Whittenham-Gray Dec 29 '15 at 10:33

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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