I'm having trouble with refreshing content in a block created with a custom module, placed within a panels page. My end goal is to display either regular or seasonal hours based on a set date range. My hook_theme()
implementation looks like the following:
function daily_hours_theme() {
if (daily_hours_is_summer()) {
$table_template = daily_hours_get_summer_vars();
} else {
$table_template = daily_hours_get_regular_vars();
}
$items = array(
'todays_hours_table' => $table_template,
'daily_hours_text_content' => array(
'render element' => 'element',
)
);
return $items;
}
I'm using hook_block_info()
to test cache settings; the following doesn't seem to have an effect on caching:
function daily_hours_block_info() {
$blocks['hours_table'] = array(
'info' => t('Daily Hours Table'),
'cache' => DRUPAL_NO_CACHE,
);
return $blocks;
}
And hook_block_view()
to call the theme function:
function daily_hours_block_view($delta = '') {
switch ($delta) {
case 'hours_table':
$block['content'] = theme('todays_hours_table');
break;
}
return $block;
}
Ideally, I'd clear the module's block data at midnight every day, but I'd settle for just knowing how to implement any caching rules in this context.
I don't have either "Cache pages for anonymous users" or "Cache blocks" set to be true
Then it's very odd that your blocks are caching. Are you using Varnish/Redis or some other caching contrib module/tool ? – No Sssweat May 10 '16 at 0:22