1

我有一个自定义 php 页面,它处理图像提要并从中制作专辑。但是,每当我将图片添加到我的提要中时,Drupal 页面在我清除缓存之前都不会改变。

有没有办法告诉 Drupal 不要缓存该特定页面?

谢谢,布莱克

编辑:Drupal v6.15 不完全确定你的意思 oswald,team2648.com/media 是 hte 页面。我使用了 php 解释器模块。这是php代码:

    <?php
//////// CODE by Pikori Web Designs - pikori.org   ///////////
//////// Please do not remove this title,          ///////////
//////// feel free to modify or copy this software ///////////
$feedURL = 'http://picasaweb.google.com/data/feed/base/user/Techplex.Engineer?alt=rss&kind=album&hl=en_US';


$photoNodeNum = 4;
$galleryTitle = 'Breakaway Pictures';
$year = '2011';
?>



<?php
  /////////////// DO NOT EDIT ANYTHING BELOW THIS LINE //////////////////

$album = $_GET['album'];
if($album != ""){

  //GENERATE PICTURES
  $feedURL= "http://".$album."&kind=photo&hl=en_US";
  $feedURL = str_replace("entry","feed",$feedURL);

  $sxml = simplexml_load_file($feedURL);
  $column = 0;
  $pix_count = count($sxml->channel->item);

  //print '<h2>'.$sxml->channel->title.'</h2>';
  print '<table cellspacing="0" cellpadding="0" style="font-size:10pt" width="100%"><tr>';
  for($i = 0; $i < $pix_count; $i++) { 

print '<td align="center">';
$entry = $sxml->channel->item[$i];
$picture_url = $entry->enclosure['url'];
$time = $entry->pubDate;
$time_ln = strlen($time)-14;
$time = substr($time,0,$time_ln);
$description = $entry->description;
$tn_beg = strpos($description, "src=");
$tn_end = strpos($description, "alt=");
$tn_length = $tn_end - $tn_beg;
$tn = substr($description, $tn_beg, $tn_length);
$tn_small = str_replace("s288","s128",$tn);

$picture_url = $tn;
$picture_beg = strpos($picture_url,"http:");
$picture_len = strlen($picture_url)-7;
$picture_url = substr($tn, $picture_beg, $picture_len);
$picture_url = str_replace("s288","s640",$picture_url);
print '<a rel="lightbox[group]" href="'.$picture_url.'">';
print '<img '.$tn_small.' style="border:1px solid #02293a"><br>';
print '</a></td> ';

if($column == 4){ print '</tr><tr>'; $column = 0;}
else $column++;
  }
  print '</table>';
  print '<br><center><a href="media">Return to album</a></center>';
} else {

  //GENERATE ALBUMS 
  $sxml = simplexml_load_file($feedURL);
  $column = 0;
  $album_count = count($sxml->channel->item);

  //print '<h2>'.$galleryTitle.'</h2>';
  print '<table cellspacing="0" cellpadding="0" style="font-size:10pt" width="100%"><tr>';
  for($i = 0; $i < $album_count; $i++) { 

$entry = $sxml->channel->item[$i];

$time = $entry->pubDate;
$time_ln = strlen($time)-14;
$time = substr($time,0,$time_ln);

$description = $entry->description;
$tn_beg = strpos($description, "src=");
$tn_end = strpos($description, "alt=");
$tn_length = $tn_end - $tn_beg;
$tn = substr($description, $tn_beg, $tn_length);

$albumrss = $entry->guid;
$albumrsscount = strlen($albumrss) - 7;
$albumrss = substr($albumrss, 7, $albumrsscount);

$search = strstr($time, $year);
if($search != FALSE || $year == ''){
  print '<td valign="top">';
  print '<a href="/node/'.$photoNodeNum.'?album='.$albumrss.'">';
  print '<center><img '.$tn.' style="border:3px double #cccccc"><br>';
  print $entry->title.'<br>'.$time.'</center>';
  print '</a><br></td> ';

  if($column == 3){ 
    print '</tr><tr>'; $column = 0;
  } else {
    $column++;
  }
} 
  }
  print '</table>';
}
?>
4

6 回答 6

2

希望这可以帮助。

这适用于 Drupal 6。

于 2011-01-12T17:01:43.773 回答
2

感谢您的回答。

您链接的网站给了我一些新的搜索词,因此我发现了这个: http ://www.drupalcoder.com/story/365-disable-drupals-page-cache-for-some-pages

然后导致我这样做: http: //drupal.org/project/cacheexclude

这正是我想要的。

于 2011-01-12T17:26:35.717 回答
1

这并没有回答您关于缓存的具体问题,但是 - 考虑使用 Drupal 原生解决方案,如Picasa模块来解决此类问题。

当您在像这里这样的 Drupal 环境中使用非 Drupal PHP 应用程序时,您会遇到与其他 Drupal 组件的奇怪交互。Drupal 模块是在考虑 Drupal 的情况下构建的,因此通常会内置诸如健全缓存之类的东西。

于 2011-01-12T21:48:18.957 回答
1

在您不想被缓存的自定义页面的顶部编写此代码行:

$GLOBALS['conf']['cache'] = FALSE;
于 2012-10-12T12:34:18.407 回答
0

对于 Drupal 6,

如果您只想从缓存中排除特定页面,则可以使用缓存排除模块,您只需提供一个 url。

对于 drupal 7,它也是可用的,但它在开发版本中。

于 2012-10-16T05:47:44.947 回答
0

是的,您可以通过编程方式进行,以下代码对 Drupal 6 和 7 均有效。

参考:http ://techrappers.com/post/27/how-prevent-javascript-and-css-render-some-drupal-pages

/**
 * Implements hook_init().
 */
function MODULE_NAME_init() {
global $conf;
// current_path() is the path on which you want to turn of JS or CSS cache
  if (current_path() == 'batch' || current_path() == 'library-admin') {
    // If you want to force CSS or JS cache to turned off
    $conf['preprocess_js'] = FALSE;
    $conf['preprocess_css'] = FALSE;

    // If you want normal caching to turned off 
     drupal_page_is_cacheable(FALSE); 
  } 
}

请注意 drupal_page_is_cacheable(FALSE); 只能关闭普通缓存,不会强制自动关闭 JS 缓存,除非你使用 $conf['preprocess_js'] = FALSE.

于 2017-03-09T04:28:56.563 回答