【问题标题】:Stop caching for a specific node (by nid) Drupal 7停止缓存特定节点(通过 nid) Drupal 7
【发布时间】:2014-09-20 09:23:51
【问题描述】:

理想情况下,我想使用 template.php

中的条件设置自定义参数以在某些特定节点中进行缓存

例如算法: 对于具有已知 nid 的节点设置自定义缓存参数

但这对于我的目的来说就足够了,只需从缓存特定节点中排除。 我喜欢这个解决方案:Stop caching for a specific node type Drupal 7 这正是我要寻找的,但我如何将检查条件从节点类型更改为 nid。

我知道CacheExclude 模块,但我不想安装模块,只排除一个节点进行缓存。

我会非常感谢你帮助我。

【问题讨论】:

    标签: caching drupal-7 drupal-theming


    【解决方案1】:

    根据您在链接中提供的示例,添加一个自定义模块,实现一个 hook_init 函数(这样做时不要忘记清除缓存)并将以下内容添加到钩子函数中:

    $node = menu_get_object();
    if (!empty($node) && $node->nid == '<NODE ID HERE>') {
      drupal_page_is_cacheable(false);
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-10
      • 2013-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多