Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change cache settings programmatically in Drupal 7

I have a block which displays list of RSS feed from an external site. I want to keep caching other blocks except the mentioned block. Howto do that?

For example, I have blockA, blockB and blockC. I only want to change the blockB's cache settings permamently to DRUPAL_NO_CACHE and leave other blocks as they are and I want to do that programmatically.

like image 738
eyurdakul Avatar asked Dec 27 '22 19:12

eyurdakul


1 Answers

You can change the caching roles in the specific module that creates youre block. In the block info like beneath:

function pref_block_info() {
  return array(
    'pref_main' => array(
      'info' => t('Display flash game for auth. users'),
      'cache' => DRUPAL_NO_CACHE,
    ),
    'pref_winner' => array(
      'info' => t('Show the winner of the last week.'),
      'cache' => DRUPAL_NO_CACHE,
    ),
    'pref_leader' => array(
      'info' => t('Show the leader of the current week.'),
      'cache' => DRUPAL_NO_CACHE,
    ),
    'pref_top' => array(
      'info' => t('Show the top 10 of the current week.'),
      'cache' => DRUPAL_NO_CACHE,
    ),
  );
}
like image 130
Jurgo Avatar answered Dec 31 '22 15:12

Jurgo