How do I empty Drupal Cache (without Devel)

前端 未结 12 2509
小鲜肉
小鲜肉 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 18:45

    HERE YOU GO:

    I had to de-install the "devel" module (it was incompatible with Special Menu Items, which I needed worse), so I made my own.

    Anywhere you see MODULENAME replace it with the name of your module.

    STEP 1: Add to any module (preferably one of your custom modules) in the HOOK_MENU, before the "return $items" line:

    // short cut for flushing the caches:
    $items['flush-cache'] = array(
      'type' => MENU_CALLBACK,
      'title' => t('Flush the cache'),
      'description' => 'MODULENAME Custom Cache Flush',
      'page callback' => 'MODULENAME_flush_cache',
      'access callback' => TRUE,
    );
    

    STEP 2: Now, in the same module file, where it's not "inside" any other function, add:

    /**  Page callback  **/
    function MODULENAME_flush_cache() {
      drupal_flush_all_caches();
      return 'Caches were flushed.';
    }
    

    Now, you can just go to the URL "/flush-cache" on your site to flush the cache. (After you flush the cache one last time the old way.)

    STEP 3: If you want it REALLY convenient, add the following to your page.tpl.php file. You can put it pretty much anywhere between and . NOTE: $my_is_test is a variable I use that's TRUE on my test system, and FALSE in production. If you don't have something like that, replace it with TRUE or FALSE to turn it on or off:

    
    flush
    
    

    And voila! You have a "flush" link at the top-right corner of every page you can click on. Feel free to change the "right" and "top" amounts (or change "right" to "left" or "top" to "bottom" to put it wherever you like it. This link positioning only works on modern browsers, but it's only for you, so it shouldn't be a problem, right?

提交回复
热议问题