How do I empty Drupal Cache (without Devel)

前端 未结 12 2575
小鲜肉
小鲜肉 2021-02-18 18:07

How do I empty the Drupal caches:

  • without the Devel module
  • without running some PHP Statement in a new node etc.
  • without going i
12条回答
  •  佛祖请我去吃肉
    2021-02-18 19:05

    The above code is for Drupal 6.

    For Drupal 7 the flush-cache module would be as follows:

     MENU_NORMAL_ITEM,
      'title' => t('Flush the cache'),
      'description' => 'Flush all website caches to make sure it updates to relect '.
        'your recent changes.',
      'page callback' => 'flush_cache_custom_callback',
      'access callback' => user_access('flush cache'),
      );
    
      return $items;
    }
    
    /**
     * Implementation of hook_permission()
     */
    function flush_cache_permission() {
      return array(
        'administer my module' => array(
          'title' => t('flush cache module'),
          'description' => t('Content admin flush cache.'),
        ),
      );
    }
    
    /**
     * Function that flushes the cache
     */
    function flush_cache_custom_callback() {
      drupal_flush_all_caches();
      return 'Caches were flushed.';
    }
    

    Note: that you then flush it by going to:

    sitename.com/flush-cache

    Make sure you give them permission on the permission page. Clear cache once the "normal" way if the permission doesn't appear after turning the module on.

    This is preferable when you don't want your client to get access to the admin menu but you still want them to be able to flush the cache.

提交回复
热议问题