2011-01-12 137 views
1

我有一个自定义的PHP页面,处理图像的饲料,并使其中的相册。然而,无论何时将图片添加到我的Feed中,直到我清除缓存时,Drupal页面才会更改。有没有办法告诉Drupal不要缓存特定页面?

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

感谢, 布雷克

编辑:Drupal的v6.15 不完全知道你的意思奥斯瓦尔德,team2648.com/media是兴田页。 我使用了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>'; 
} 
?> 
+1

请指定您使用的Drupal版本。在Drupal 7中更改了缓存。另外,您是如何实现页面的? – Oswald 2011-01-12 16:42:35

回答

2

Hope this helps.

这是为Drupal 6

+0

所以这不是我可以放在页面底部的代码片段?这看起来像我必须制作我自己的模块。此外,能够在多个页面上使用它将会很好。 – TechplexEngineer 2011-01-12 17:15:49

1

这并不回答您关于缓存的具体问题,但 - 考虑使用Drupal本机解决方案,如Picasa模块。

当您在Drupal环境中使用非Drupal PHP应用程序(如您在此处)时,您会与其他Drupal组件发生奇怪的交互。 Drupal模块是在你不自定义页面的顶部建有Drupal一点,所以像健全缓存通常会建在

+0

这将是一个很好的模块来做我想做的事情,但是我无法让Picasa模块正常工作。谷歌告诉我,它收到了一个畸形的请求。 – TechplexEngineer 2011-01-17 14:02:12

1

写这行代码希望缓存:

$GLOBALS['conf']['cache'] = FALSE; 
0

为Drupal 6,

如果你只是想排除一个特定的页面被缓存,那么你可以使用缓存排除模块,在那里你只需要提供一个url。

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

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);只能关闭正常缓存,除非使用$ conf ['preprocess_js'] = FALSE,否则不会强制JS缓存自动关闭。

相关问题