2011-01-12 141 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緩存自動關閉。

相關問題