在Drupal 7中以编程方式更改缓存设置

eyu*_*kul 4 drupal drupal-7

我有一个块,它显示来自外部站点的RSS feed列表。我想继续缓存除提到的块以外的其他块。怎么做?

例如,我有blockAblockBblockC。我只想永久地将blockB的缓存设置更改为DRUPAL_NO_CACHE其他块,而其他块则保持不变,而我想以编程方式进行操作。

Jur*_*rgo 5

您可以在创建您的块的特定模块中更改缓存角色。在下面的块信息中:

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,
    ),
  );
}
Run Code Online (Sandbox Code Playgroud)