I needed to create a module that alters the behavior of splashify to limit the time-window for a splash page to appear (e.g. show on New Year's Day). The most straightforward way to do that was alter the $config variable in splashify.display.inc after it has been read in but before any logic happens. So I did the following:
<?php
$config = _splashify_get_config();
// permit other modules to modify $config
drupal_alter('splashify_config', $config);
>?

Now in my module, I did a hook_form_alter, including submit and validate handers, to manage my configuration settings, and I added a function MYMODULE_splashify_config_alter(&$config) {}, which changes splashify's $config['when_frequency'] to 'never' as appropriate for my application.

Attached is a patch against 7.x-1.x-dev.

Thanks!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pdcarto’s picture

Status: Active » Needs review
pdcarto’s picture

If anyone is interested, I created a sandbox project of my Splashify Date Range add-on module: http://drupal.org/sandbox/patdunlavey/1887498

chrisroane’s picture

If I am understanding this correctly, this would not handle Anonymous Page Caching correctly. I'm hesitant to implement this as a hook because it would only work with anonymous page caching off.

This type of feature could be implement by adding a new config option in the admin and then sending this specified date value to the JS. My hesitation is that I don't know if this feature is justified adding to Splashify, with all the other features that are a part of this module. At this point I'm thinking this is a feature that I will implement with the 2.x version of the module that I will launch with Drupal 8.

Thanks for sharing the code though!

chrisroane’s picture

Status: Needs review » Postponed
pdcarto’s picture

Excellent point about anonymous page caching, though honestly I do not understand caching very well, or how splashify's 'when' operation depends on that caching. Thanks for keeping this in mind for the 2.x version!

chrisroane’s picture

Issue summary: View changes

FYI...I added this feature to the list of features to add to the D8 version:
https://www.drupal.org/node/1860218#comment-9342387

chrisroane’s picture

Status: Postponed » Closed (won't fix)
asherry’s picture

Status: Closed (won't fix) » Active

Sorry to bring this up again, I just have a few thoughts.

@chrisroane - With the solution that @pdcarto suggested it doesn't seem like this module would actually have to worry about the page caching, that would be his module's problem. I don't think you should deny the drupal alter because of how his module might or might not handle it, there could be many other reasons other sites have to alter this module, the burden lies on them to use it properly.

With that said, a potential solution to the anonymous caching problem could be to add a cron hook that looks for the 'from' and 'to' dates specified in the configuration, and clears page cache on those two occasions so that the display will change.

I have a feeling I'm going to implement something like that, it would at least be nice to have that drupal alter hook inside this module so that I can use the base code from here. I'd be happy to share the cache code when I work that out.

Thanks!

asherry’s picture

FileSize
8.73 KB

Here's an implementation, (with a cron hook) that works for me, although I haven't tested it on anything other than colorbox. Hopefully you'll still give this feature some consideration.
This is a great module for not having to load in jStorage and colorbox, but really without some sort of automated on and off it is going to be unusable for our clients.

I'd either like to see this implemented, or the original request for an alter put in so that I can create a custom module for our particular need.

Thank you!

asherry’s picture

Status: Active » Needs review
asherry’s picture

sorry, in the last patch the cache function should be cache_clear_all(), that's the one that works.